Java Code Examples for android.widget.FrameLayout#MarginLayoutParams

The following examples show how to use android.widget.FrameLayout#MarginLayoutParams . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From CutIntoLayout with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final int quarterHeight = getWindowManager().getDefaultDisplay().getHeight() / 5;

    final CutIntoLayout cutIntoLayout = (CutIntoLayout) findViewById(R.id.cut_into_layout);
    ((FrameLayout.MarginLayoutParams) cutIntoLayout.getLayoutParams()).topMargin = quarterHeight / 2;

    final Animation slideAnimation = new TranslateAnimation(0.0F, 0.0F, 0.0F, quarterHeight * 2.5F);
    slideAnimation.setDuration(2000);
    slideAnimation.setRepeatCount(Animation.INFINITE);
    slideAnimation.setRepeatMode(Animation.REVERSE);

    cutIntoLayout.startAnimation(slideAnimation);
}
 
Example 2
Source File: PreferencesActivity.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences Sp = PreferenceManager.getDefaultSharedPreferences(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.prefsfrag);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze",
                ((BitmapDrawable) getResources().getDrawable(R.drawable.ic_launcher)).getBitmap(),
                getColorPreference().getColor(ColorUsage.PRIMARY));
        setTaskDescription(taskDescription);
    }
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_HOME_AS_UP | android.support.v7.app.ActionBar.DISPLAY_SHOW_TITLE);
    getSupportActionBar().setBackgroundDrawable(getColorPreference().getDrawable(ColorUsage.PRIMARY));

    if (SDK_INT == 20 || SDK_INT == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(getColorPreference().getColor(ColorUsage.PRIMARY));

        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.preferences).getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (SDK_INT >= 21) {
        boolean colourednavigation = Sp.getBoolean("colorednavigation", true);
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(PreferenceUtils.getStatusColor(getColorPreference().getColorAsString(ColorUsage.PRIMARY)));
        if (colourednavigation)
            window.setNavigationBarColor(PreferenceUtils.getStatusColor(getColorPreference().getColorAsString(ColorUsage.PRIMARY)));

    }
    if (savedInstanceState != null){
        selectedItem = savedInstanceState.getInt(KEY_CURRENT_FRAG_OPEN, 0);
    }
    selectItem(selectedItem);
}
 
Example 3
Source File: ExplorerActivity.java    From PowerFileExplorer with GNU General Public License v3.0 4 votes vote down vote up
void initialiseViews() {

//        mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer);
//        if (getAppTheme().equals(AppTheme.DARK)) 
//			mDrawerLinear.setBackgroundColor(Utils.getColor(this, R.color.holo_dark_background));
//        else 
//			mDrawerLinear.setBackgroundColor(Color.WHITE);
//        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
//        //mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin)));
//        mDrawerList = (ListView) findViewById(R.id.menu_drawer);
//        drawerHeaderView.setBackgroundResource(R.drawable.amaze_header);
//        //drawerHeaderParent.setBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin)));
//        if (findViewById(R.id.tab_frame) != null) {
//            mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear);
//            mDrawerLayout.openDrawer(mDrawerLinear);
//            mDrawerLayout.setScrimColor(Color.TRANSPARENT);
//            isDrawerLocked = true;
//        } else if (findViewById(R.id.tab_frame) == null) {

//		mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawerList);
//            mDrawerLayout.closeDrawer(mDrawerList);
//            isDrawerLocked = false;
////        }
//        View settingsButton = findViewById(R.id.settingsbutton);
//        if (getAppTheme().equals(AppTheme.DARK)) {
//            settingsButton.setBackgroundResource(R.drawable.safr_ripple_black);
//            ((ImageView) settingsButton.findViewById(R.id.settingicon)).setImageResource(R.drawable.ic_settings_white_48dp);
//            ((TextView) settingsButton.findViewById(R.id.settingtext)).setTextColor(Utils.getColor(this, android.R.color.white));
//        }
//        settingsButton.setOnClickListener(new View.OnClickListener() {
//				@Override
//				public void onClick(View v) {
//					Intent in = new Intent(ExplorerActivity.this, PreferencesActivity.class);
//					startActivity(in);
//					finish();
//				}
//
//			});
//        View appButton = findViewById(R.id.appbutton);
//        if (getAppTheme().equals(AppTheme.DARK)) {
//            appButton.setBackgroundResource(R.drawable.safr_ripple_black);
//            ((ImageView) appButton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white);
//            ((TextView) appButton.findViewById(R.id.apptext)).setTextColor(Utils.getColor(this, android.R.color.white));
//        }
//        appButton.setOnClickListener(new View.OnClickListener() {
//				@Override
//				public void onClick(View v) {
//					android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager().beginTransaction();
//					transaction2.replace(R.id.content_frame, new AppsList());
//					//appBarLayout.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
//					pending_fragmentTransaction = transaction2;
//					if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerList);
//					else onDrawerClosed();
//					selectedStorage = SELECT_MINUS_2;
//					adapter.toggleChecked(false);
//				}
//			});
//
//        View ftpButton = findViewById(R.id.ftpbutton);
//        if (getAppTheme().equals(AppTheme.DARK)) {
//            ftpButton.setBackgroundResource(R.drawable.safr_ripple_black);
//            ((ImageView) ftpButton.findViewById(R.id.ftpicon)).setImageResource(R.drawable.ic_ftp_dark);
//            ((TextView) ftpButton.findViewById(R.id.ftptext)).setTextColor(Utils.getColor(this, android.R.color.white));
//        }
//        ftpButton.setOnClickListener(new View.OnClickListener() {
//
//				@Override
//				public void onClick(View v) {
//					android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager().beginTransaction();
//					transaction2.replace(R.id.content_frame, new FTPServerFragment());
//					//appBarLayout.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
//					pending_fragmentTransaction = transaction2;
//					if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerList);
//					else onDrawerClosed();
//					selectedStorage = SELECT_MINUS_2;
//					adapter.toggleChecked(false);
//				}
//			});
        //getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor((currentTab==1 ? skinTwo : skin))));

        // status bar0
        if (SDK_INT == 20 || SDK_INT == 19) {
            SystemBarTintManager tintManager = new SystemBarTintManager(this);
            tintManager.setStatusBarTintEnabled(true);
            //tintManager.setStatusBarTintColor(Color.parseColor((currentTab==1 ? skinTwo : skin)));
            FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout).getLayoutParams();
            SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
            if (!isDrawerLocked) p.setMargins(0, config.getStatusBarHeight(), 0, 0);
        } else if (SDK_INT >= 21) {
//            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//            if (isDrawerLocked) {
//                window.setStatusBarColor(skinStatusBar);
//            } else {
//				window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//			}
            if (colourednavigation)
                window.setNavigationBarColor(skinStatusBar);
        }
    }