List of usage examples for android.widget FrameLayout getLayoutParams
@ViewDebug.ExportedProperty(deepExport = true, prefix = "layout_") public ViewGroup.LayoutParams getLayoutParams()
From source file:tv.ouya.sdk.CordovaOuyaPlugin.java
protected void setSafeArea(CallbackContext callback, final float progress) { final Activity activity = cordova.getActivity(); if (null != activity) { Runnable runnable = new Runnable() { public void run() { // bring in by % float percent = 0.1f; float ratio = 1 - (1 - progress) * percent; float halfRatio = 1 - (1 - progress) * percent * 0.5f; float maxWidth = getDisplayWidth(); float maxHeight = getDisplayHeight(); FrameLayout content = (FrameLayout) activity.findViewById(android.R.id.content); ViewGroup.LayoutParams layout = content.getLayoutParams(); layout.width = (int) (maxWidth * ratio); layout.height = (int) (maxHeight * ratio); content.setLayoutParams(layout); content.setX(maxWidth - maxWidth * halfRatio); content.setY(maxHeight - maxHeight * halfRatio); }/*w ww . j a va2s .c om*/ }; activity.runOnUiThread(runnable); } callback.success(); }
From source file:com.b44t.ui.Components.PasscodeView.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int width = MeasureSpec.getSize(widthMeasureSpec); int height = AndroidUtilities.displaySize.y - (Build.VERSION.SDK_INT >= 21 ? 0 : AndroidUtilities.statusBarHeight); LayoutParams layoutParams;/* ww w . ja va2 s .c om*/ if (!AndroidUtilities.isTablet() && getContext().getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams(); layoutParams.width = UserConfig.passcodeType == 0 ? width / 2 : width; layoutParams.height = AndroidUtilities.dp(140); layoutParams.topMargin = (height - AndroidUtilities.dp(140)) / 2; passwordFrameLayout.setLayoutParams(layoutParams); layoutParams = (LayoutParams) numbersFrameLayout.getLayoutParams(); layoutParams.height = height; layoutParams.leftMargin = width / 2; layoutParams.topMargin = height - layoutParams.height; layoutParams.width = width / 2; numbersFrameLayout.setLayoutParams(layoutParams); } else { int top = 0; int left = 0; if (AndroidUtilities.isTablet()) { if (width > AndroidUtilities.dp(498)) { left = (width - AndroidUtilities.dp(498)) / 2; width = AndroidUtilities.dp(498); } if (height > AndroidUtilities.dp(528)) { top = (height - AndroidUtilities.dp(528)) / 2; height = AndroidUtilities.dp(528); } } layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams(); layoutParams.height = height / 3; layoutParams.width = width; layoutParams.topMargin = top; layoutParams.leftMargin = left; passwordFrameLayout.setTag(top); passwordFrameLayout.setLayoutParams(layoutParams); layoutParams = (LayoutParams) numbersFrameLayout.getLayoutParams(); layoutParams.height = height / 3 * 2; layoutParams.leftMargin = left; layoutParams.topMargin = height - layoutParams.height + top; layoutParams.width = width; numbersFrameLayout.setLayoutParams(layoutParams); } int sizeBetweenNumbersX = (layoutParams.width - AndroidUtilities.dp(50) * 3) / 4; int sizeBetweenNumbersY = (layoutParams.height - AndroidUtilities.dp(50) * 4) / 5; for (int a = 0; a < 11; a++) { LayoutParams layoutParams1; int num; if (a == 0) { num = 10; } else if (a == 10) { num = 11; } else { num = a - 1; } int row = num / 3; int col = num % 3; int top; if (a < 10) { TextView textView = numberTextViews.get(a); TextView textView1 = lettersTextViews.get(a); layoutParams = (LayoutParams) textView.getLayoutParams(); layoutParams1 = (LayoutParams) textView1.getLayoutParams(); top = layoutParams1.topMargin = layoutParams.topMargin = sizeBetweenNumbersY + (sizeBetweenNumbersY + AndroidUtilities.dp(50)) * row; layoutParams1.leftMargin = layoutParams.leftMargin = sizeBetweenNumbersX + (sizeBetweenNumbersX + AndroidUtilities.dp(50)) * col; layoutParams1.topMargin += AndroidUtilities.dp(40); textView.setLayoutParams(layoutParams); textView1.setLayoutParams(layoutParams1); } else { layoutParams = (LayoutParams) eraseView.getLayoutParams(); top = layoutParams.topMargin = sizeBetweenNumbersY + (sizeBetweenNumbersY + AndroidUtilities.dp(50)) * row + AndroidUtilities.dp(8); layoutParams.leftMargin = sizeBetweenNumbersX + (sizeBetweenNumbersX + AndroidUtilities.dp(50)) * col; top -= AndroidUtilities.dp(8); eraseView.setLayoutParams(layoutParams); } FrameLayout frameLayout = numberFrameLayouts.get(a); layoutParams1 = (LayoutParams) frameLayout.getLayoutParams(); layoutParams1.topMargin = top - AndroidUtilities.dp(17); layoutParams1.leftMargin = layoutParams.leftMargin - AndroidUtilities.dp(25); frameLayout.setLayoutParams(layoutParams1); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
From source file:org.bohrmeista.chan.ui.activity.BoardActivity.java
private void updatePaneState() { DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int width = metrics.widthPixels; FrameLayout left = (FrameLayout) findViewById(R.id.left_pane); FrameLayout right = (FrameLayout) findViewById(R.id.right_pane); LayoutParams leftParams = left.getLayoutParams(); LayoutParams rightParams = right.getLayoutParams(); boolean wasSlidable = threadPane.isSlideable(); boolean isSlidable; // Content view dp's: // Nexus 4 is 384 x 640 dp // Nexus 7 is 600 x 960 dp // Nexus 10 is 800 x 1280 dp if (ChanPreferences.getForcePhoneLayout()) { leftParams.width = width - Utils.dp(30); rightParams.width = width;//from w w w. j ava 2 s .c o m isSlidable = true; } else { if (width < Utils.dp(400)) { leftParams.width = width - Utils.dp(30); rightParams.width = width; isSlidable = true; } else if (width < Utils.dp(800)) { leftParams.width = width - Utils.dp(60); rightParams.width = width; isSlidable = true; } else if (width < Utils.dp(1000)) { leftParams.width = Utils.dp(300); rightParams.width = width - Utils.dp(300); isSlidable = false; } else { leftParams.width = Utils.dp(400); rightParams.width = width - Utils.dp(400); isSlidable = false; } } left.setLayoutParams(leftParams); right.setLayoutParams(rightParams); threadPane.requestLayout(); left.requestLayout(); right.requestLayout(); LayoutParams drawerParams = pinDrawerView.getLayoutParams(); if (width < Utils.dp(340)) { drawerParams.width = Utils.dp(280); } else { drawerParams.width = Utils.dp(320); } pinDrawerView.setLayoutParams(drawerParams); updateActionBarState(); if (isSlidable != wasSlidable) { // Terrible hack to sync state for some devices when it changes slidable mode threadPane.postDelayed(new Runnable() { @Override public void run() { updateActionBarState(); } }, 1000); } }
From source file:com.h6ah4i.android.example.advrecyclerview.demo_eds_vp_sec_long.MyExpandableDraggableSwipeableSectionAdapter.java
private void onBindItemGroupViewHolder(MyGroupViewHolder holder, int groupPosition) { // group item final AbstractExpandableDataProvider.GroupData item = mProvider.getGroupItem(groupPosition); // set listeners holder.itemView.setOnClickListener(mItemViewOnClickListener); // set text// w w w . j a v a 2 s. c o m holder.mTextView.setText(item.getText()); // set background resource (target view ID: container) final int dragState = holder.getDragStateFlags(); final int expandState = holder.getExpandStateFlags(); final int swipeState = holder.getSwipeStateFlags(); if (((dragState & Draggable.STATE_FLAG_IS_UPDATED) != 0) || ((expandState & Expandable.STATE_FLAG_IS_UPDATED) != 0) || ((swipeState & Swipeable.STATE_FLAG_IS_UPDATED) != 0)) { int bgResId; boolean isExpanded; boolean animateIndicator = ((expandState & Expandable.STATE_FLAG_HAS_EXPANDED_STATE_CHANGED) != 0); if ((dragState & Draggable.STATE_FLAG_IS_ACTIVE) != 0) { bgResId = R.drawable.bg_group_item_dragging_active_state; // need to clear drawable state here to get correct appearance of the dragging item. DrawableUtils.clearState(holder.mContainer.getForeground()); } else if ((dragState & Draggable.STATE_FLAG_DRAGGING) != 0) { bgResId = R.drawable.bg_group_item_dragging_state; } else if ((swipeState & Swipeable.STATE_FLAG_IS_ACTIVE) != 0) { //The One being swipe bgResId = R.drawable.bg_group_item_swiping_active_state; } else if ((swipeState & Swipeable.STATE_FLAG_SWIPING) != 0) { //The others... bgResId = R.drawable.bg_group_item_swiping_state; } else if ((expandState & Expandable.STATE_FLAG_IS_EXPANDED) != 0) { bgResId = R.drawable.bg_group_item_expanded_state; } else { bgResId = R.drawable.bg_group_item_normal_state; } if ((expandState & Expandable.STATE_FLAG_IS_EXPANDED) != 0) { isExpanded = true; } else { isExpanded = false; } holder.mContainer.setBackgroundResource(bgResId); /* Testing Layout change while expanding */ FrameLayout parent = ((FrameLayout) holder.mContainer.getParent()); ViewGroup.LayoutParams lp = parent.getLayoutParams(); lp.height = parent.getContext().getResources().getDimensionPixelSize(R.dimen.list_group_item_height); if (isExpanded) lp.height += 20; parent.setLayoutParams(lp); holder.mIndicator.setExpandedState(isExpanded, animateIndicator); } // set swiping properties holder.setSwipeItemHorizontalSlideAmount(item.isPinned() ? Swipeable.OUTSIDE_OF_THE_WINDOW_LEFT : 0); }
From source file:info.tellmetime.TellmetimeActivity.java
/** * Handles changing highlight color via #mSeekBarHighlight. * * @param value indicates exact offset in gradient (SeekBar's max value is equal to #mRainbow width). *///from w w w .j a v a 2 s.co m @Override public void onProgressChanged(SeekBar seekBar, int value, boolean fromUser) { switch (seekBar.getId()) { case R.id.highlightValue: mHighlightColor = mRainbow.getPixel(value, 0); if (((RadioButton) findViewById(R.id.radio_backlight_highlight)).isChecked()) { float[] highlightHSV = new float[3]; Color.colorToHSV(mHighlightColor, highlightHSV); mBacklightColor = Color.HSVToColor(33, highlightHSV); } if (fromUser) mHighlightPosition = (float) value / seekBar.getMax(); mClockAlgorithm.tickTock(); break; case R.id.minutesSize: mMinutesSize = value; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { FrameLayout minutesIndicators = (FrameLayout) findViewById(R.id.minutes_indicators); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) minutesIndicators .getLayoutParams(); params.topMargin = (int) -TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize / 3, getResources().getDisplayMetrics()); minutesIndicators.setLayoutParams(params); } ViewGroup minutesDots = (ViewGroup) findViewById(R.id.minutes_dots); for (int i = 0; i < minutesDots.getChildCount(); i++) { TextView m = (TextView) minutesDots.getChildAt(i); m.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize); } break; } mHider.delayedHide(4000); }
From source file:com.b44t.ui.Components.PasscodeView.java
public PasscodeView(final Context context) { super(context); setWillNotDraw(false);//from ww w . j a v a2 s . c o m setVisibility(GONE); backgroundFrameLayout = new FrameLayout(context); addView(backgroundFrameLayout); LayoutParams layoutParams = (LayoutParams) backgroundFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; backgroundFrameLayout.setLayoutParams(layoutParams); passwordFrameLayout = new FrameLayout(context); addView(passwordFrameLayout); layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; passwordFrameLayout.setLayoutParams(layoutParams); ImageView imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setImageResource(R.drawable.ic_launcher /* EDIT BY MR -- was: passcode_logo */); passwordFrameLayout.addView(imageView); layoutParams = (LayoutParams) imageView.getLayoutParams(); if (AndroidUtilities.density < 1) { layoutParams.width = AndroidUtilities.dp(30); layoutParams.height = AndroidUtilities.dp(30); } else { layoutParams.width = AndroidUtilities.dp(40); layoutParams.height = AndroidUtilities.dp(40); } layoutParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; layoutParams.bottomMargin = AndroidUtilities.dp(100); imageView.setLayoutParams(layoutParams); passcodeTextView = new TextView(context); passcodeTextView.setTextColor(0xffffffff); passcodeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); passcodeTextView.setGravity(Gravity.CENTER_HORIZONTAL); passwordFrameLayout.addView(passcodeTextView); layoutParams = (LayoutParams) passcodeTextView.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.bottomMargin = AndroidUtilities.dp(62); layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; passcodeTextView.setLayoutParams(layoutParams); passwordEditText = new EditText(context); passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36); passwordEditText.setTextColor(0xffffffff); passwordEditText.setMaxLines(1); passwordEditText.setLines(1); passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL); passwordEditText.setSingleLine(true); passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); passwordEditText.setTypeface(Typeface.DEFAULT); passwordEditText.setBackgroundDrawable(null); AndroidUtilities.clearCursorDrawable(passwordEditText); passwordFrameLayout.addView(passwordEditText); layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams(); layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(70); layoutParams.rightMargin = AndroidUtilities.dp(70); layoutParams.bottomMargin = AndroidUtilities.dp(6); layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; passwordEditText.setLayoutParams(layoutParams); passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_DONE) { processDone(false); return true; } return false; } }); passwordEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (passwordEditText.length() == 4 && UserConfig.passcodeType == 0) { processDone(false); } } }); passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public void onDestroyActionMode(ActionMode mode) { } public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } }); checkImage = new ImageView(context); checkImage.setImageResource(R.drawable.passcode_check); checkImage.setScaleType(ImageView.ScaleType.CENTER); checkImage.setBackgroundResource(R.drawable.bar_selector_lock); passwordFrameLayout.addView(checkImage); layoutParams = (LayoutParams) checkImage.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(60); layoutParams.height = AndroidUtilities.dp(60); layoutParams.bottomMargin = AndroidUtilities.dp(4); layoutParams.rightMargin = AndroidUtilities.dp(10); layoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT; checkImage.setLayoutParams(layoutParams); checkImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { processDone(false); } }); FrameLayout lineFrameLayout = new FrameLayout(context); lineFrameLayout.setBackgroundColor(0x26ffffff); passwordFrameLayout.addView(lineFrameLayout); layoutParams = (LayoutParams) lineFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(1); layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT; layoutParams.leftMargin = AndroidUtilities.dp(20); layoutParams.rightMargin = AndroidUtilities.dp(20); lineFrameLayout.setLayoutParams(layoutParams); numbersFrameLayout = new FrameLayout(context); addView(numbersFrameLayout); layoutParams = (LayoutParams) numbersFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; numbersFrameLayout.setLayoutParams(layoutParams); lettersTextViews = new ArrayList<>(10); numberTextViews = new ArrayList<>(10); numberFrameLayouts = new ArrayList<>(10); for (int a = 0; a < 10; a++) { TextView textView = new TextView(context); textView.setTextColor(0xffffffff); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36); textView.setGravity(Gravity.CENTER); textView.setText(String.format(Locale.US, "%d", a)); numbersFrameLayout.addView(textView); layoutParams = (LayoutParams) textView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(50); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; textView.setLayoutParams(layoutParams); numberTextViews.add(textView); textView = new TextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); textView.setTextColor(0x7fffffff); textView.setGravity(Gravity.CENTER); numbersFrameLayout.addView(textView); layoutParams = (LayoutParams) textView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(20); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; textView.setLayoutParams(layoutParams); switch (a) { case 0: textView.setText("+"); break; case 2: textView.setText("ABC"); break; case 3: textView.setText("DEF"); break; case 4: textView.setText("GHI"); break; case 5: textView.setText("JKL"); break; case 6: textView.setText("MNO"); break; case 7: textView.setText("PQRS"); break; case 8: textView.setText("TUV"); break; case 9: textView.setText("WXYZ"); break; default: break; } lettersTextViews.add(textView); } eraseView = new ImageView(context); eraseView.setScaleType(ImageView.ScaleType.CENTER); eraseView.setImageResource(R.drawable.passcode_delete); numbersFrameLayout.addView(eraseView); layoutParams = (LayoutParams) eraseView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(50); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; eraseView.setLayoutParams(layoutParams); for (int a = 0; a < 11; a++) { FrameLayout frameLayout = new FrameLayout(context); frameLayout.setBackgroundResource(R.drawable.bar_selector_lock); frameLayout.setTag(a); if (a == 10) { frameLayout.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { passwordEditText.setText(""); return true; } }); } frameLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int tag = (Integer) v.getTag(); switch (tag) { case 0: appendCharacter("0"); break; case 1: appendCharacter("1"); break; case 2: appendCharacter("2"); break; case 3: appendCharacter("3"); break; case 4: appendCharacter("4"); break; case 5: appendCharacter("5"); break; case 6: appendCharacter("6"); break; case 7: appendCharacter("7"); break; case 8: appendCharacter("8"); break; case 9: appendCharacter("9"); break; case 10: String text = passwordEditText.getText().toString(); if (text.length() > 0) { passwordEditText.setText(text.substring(0, text.length() - 1)); } break; } if (passwordEditText.getText().toString().length() == 4) { processDone(false); } } }); numberFrameLayouts.add(frameLayout); } for (int a = 10; a >= 0; a--) { FrameLayout frameLayout = numberFrameLayouts.get(a); numbersFrameLayout.addView(frameLayout); layoutParams = (LayoutParams) frameLayout.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(100); layoutParams.height = AndroidUtilities.dp(100); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; frameLayout.setLayoutParams(layoutParams); } }
From source file:com.sonaive.v2ex.ui.BaseActivity.java
/** * Sets up the navigation drawer as appropriate. Note that the nav drawer will be * different depending on whether the attendee indicated that they are attending the * event on-site vs. attending remotely. */// w w w .j a va 2s . c o m private void setupNavDrawer() { // What nav drawer item should be selected? int selfItem = getSelfNavDrawerItem(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); ScrollView navContent = (ScrollView) findViewById(R.id.navdrawer); if (mDrawerLayout == null || navContent == null) { return; } FrameLayout mainContent = (FrameLayout) findViewById(R.id.main_content); // set static navigation drawer if (mainContent != null && ((ViewGroup.MarginLayoutParams) mainContent.getLayoutParams()).leftMargin == (int) getResources() .getDimension(R.dimen.navdrawer_width)) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, navContent); mDrawerLayout.setScrimColor(Color.TRANSPARENT); } mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.theme_primary_dark)); ScrimInsetsScrollView navDrawer = (ScrimInsetsScrollView) mDrawerLayout.findViewById(R.id.navdrawer); if (selfItem == NAVDRAWER_ITEM_INVALID) { // do not show a nav drawer if (navDrawer != null) { ((ViewGroup) navDrawer.getParent()).removeView(navDrawer); } mDrawerLayout = null; return; } if (navDrawer != null) { final View chosenAccountContentView = findViewById(R.id.chosen_account_content_view); final View chosenAccountView = findViewById(R.id.chosen_account_view); final int navDrawerChosenAccountHeight = getResources() .getDimensionPixelSize(R.dimen.navdrawer_chosen_account_height); navDrawer.setOnInsetsCallback(new ScrimInsetsScrollView.OnInsetsCallback() { @Override public void onInsetsChanged(Rect insets) { ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) chosenAccountContentView .getLayoutParams(); lp.topMargin = insets.top; chosenAccountContentView.setLayoutParams(lp); ViewGroup.LayoutParams lp2 = chosenAccountView.getLayoutParams(); lp2.height = navDrawerChosenAccountHeight + insets.top; chosenAccountView.setLayoutParams(lp2); } }); } if (mActionBarToolbar != null) { mActionBarToolbar.setNavigationIcon(R.drawable.ic_drawer); mActionBarToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mDrawerLayout.openDrawer(Gravity.START); } }); } mDrawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() { @Override public void onDrawerClosed(View drawerView) { // run deferred action, if we have one if (mDeferredOnDrawerClosedRunnable != null) { mDeferredOnDrawerClosedRunnable.run(); mDeferredOnDrawerClosedRunnable = null; } if (mAccountBoxExpanded) { mAccountBoxExpanded = false; setupAccountBoxToggle(); } onNavDrawerStateChanged(false, false); } @Override public void onDrawerOpened(View drawerView) { onNavDrawerStateChanged(true, false); } @Override public void onDrawerStateChanged(int newState) { onNavDrawerStateChanged(isNavDrawerOpen(), newState != DrawerLayout.STATE_IDLE); } @Override public void onDrawerSlide(View drawerView, float slideOffset) { onNavDrawerSlide(slideOffset); } }); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); // populate the nav drawer with the correct items populateNavDrawer(); }
From source file:com.concentricsky.android.khanacademy.app.VideoDetailActivity.java
private void goLargeLandscape() { isFullscreen = false;//from w w w.j ava2 s .c om setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); VideoController videoControls = (VideoController) findViewById(R.id.controller); if (videoControls != null) { videoControls.setFullscreen(false); } ThumbnailWrapper videoContainer = (ThumbnailWrapper) findViewById(R.id.video_fragment_container); videoContainer.setMaintainAspectRatio(true); FrameLayout headerContainer = (FrameLayout) findViewById(R.id.detail_header_container); LinearLayout.LayoutParams p = (LinearLayout.LayoutParams) headerContainer.getLayoutParams(); p.weight = 1; headerContainer.setLayoutParams(p); headerContainer.setVisibility(View.VISIBLE); FrameLayout emptyContainer = (FrameLayout) findViewById(R.id.detail_bottom_container); p = (LinearLayout.LayoutParams) emptyContainer.getLayoutParams(); p.weight = 0; emptyContainer.setLayoutParams(p); emptyContainer.setVisibility(View.GONE); findViewById(R.id.detail_right_container).setVisibility(View.VISIBLE); createAndAttachCaptionFragment(R.id.detail_right_caption_container); createAndAttachHeader(); findViewById(R.id.detail_center_divider).setVisibility(View.VISIBLE); getDecorViewTreeObserver().addOnGlobalLayoutListener(layoutFixer); }
From source file:com.concentricsky.android.khanacademy.app.VideoDetailActivity.java
private void goPortrait() { isFullscreen = false;//w w w .j a va 2s . c o m setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); VideoController videoControls = (VideoController) findViewById(R.id.controller); if (videoControls != null) { videoControls.setFullscreen(false); } ThumbnailWrapper videoContainer = (ThumbnailWrapper) findViewById(R.id.video_fragment_container); videoContainer.setMaintainAspectRatio(true); FrameLayout headerContainer = (FrameLayout) findViewById(R.id.detail_header_container); LinearLayout.LayoutParams p = (LinearLayout.LayoutParams) headerContainer.getLayoutParams(); p.weight = 0; headerContainer.setLayoutParams(p); createAndAttachCaptionFragment(R.id.detail_bottom_container); FrameLayout captionContainer = (FrameLayout) findViewById(R.id.detail_bottom_container); captionContainer.setVisibility(View.VISIBLE); p = (LinearLayout.LayoutParams) captionContainer.getLayoutParams(); p.weight = 1; captionContainer.setLayoutParams(p); if (isBigScreen) { findViewById(R.id.detail_right_container).setVisibility(View.GONE); findViewById(R.id.detail_center_divider).setVisibility(View.GONE); } setNavVisibility(true); createAndAttachHeader(); getDecorViewTreeObserver().addOnGlobalLayoutListener(layoutFixer); }
From source file:com.openatk.fieldnotebook.MainActivity.java
private void hideDrawing(Boolean transition) { if (drawingIsShowing == 1) { drawingIsShowing = 0;/*from www . jav a2 s . com*/ FragmentManager fm = getSupportFragmentManager(); FragmentDrawing fragment = (FragmentDrawing) fm.findFragmentByTag("drawing"); // Set height so transition works FrameLayout layout = (FrameLayout) findViewById(R.id.fragment_container_drawing); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams(); params.height = fragment.getHeight(); layout.setLayoutParams(params); // Do transition FragmentTransaction ft = fm.beginTransaction(); if (transition) ft.setCustomAnimations(R.anim.slide_down2, R.anim.slide_up2); ft.remove(fragment); ft.commit(); fragmentDrawing = null; } this.invalidateOptionsMenu(); }