List of usage examples for android.view Gravity BOTTOM
int BOTTOM
To view the source code for android.view Gravity BOTTOM.
Click Source Link
From source file:com.farmerbb.taskbar.activity.ContextMenuActivity.java
@SuppressLint("RtlHardcoded") @SuppressWarnings("deprecation") @Override// w ww .j a v a 2 s. c o m protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); LocalBroadcastManager.getInstance(this) .sendBroadcast(new Intent("com.farmerbb.taskbar.CONTEXT_MENU_APPEARING")); boolean isNonAppMenu = !getIntent().hasExtra("package_name") && !getIntent().hasExtra("app_name"); showStartMenu = getIntent().getBooleanExtra("launched_from_start_menu", false); isStartButton = isNonAppMenu && getIntent().getBooleanExtra("is_start_button", false); isOverflowMenu = isNonAppMenu && getIntent().getBooleanExtra("is_overflow_menu", false); contextMenuFix = getIntent().hasExtra("context_menu_fix"); // Determine where to position the dialog on screen WindowManager.LayoutParams params = getWindow().getAttributes(); DisplayManager dm = (DisplayManager) getSystemService(DISPLAY_SERVICE); Display display = dm.getDisplay(Display.DEFAULT_DISPLAY); int statusBarHeight = 0; int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) statusBarHeight = getResources().getDimensionPixelSize(resourceId); if (showStartMenu) { int x = getIntent().getIntExtra("x", 0); int y = getIntent().getIntExtra("y", 0); int offset = getResources().getDimensionPixelSize( isOverflowMenu ? R.dimen.context_menu_offset_overflow : R.dimen.context_menu_offset); switch (U.getTaskbarPosition(this)) { case "bottom_left": case "bottom_vertical_left": params.gravity = Gravity.BOTTOM | Gravity.LEFT; params.x = x; params.y = display.getHeight() - y - offset; break; case "bottom_right": case "bottom_vertical_right": params.gravity = Gravity.BOTTOM | Gravity.LEFT; params.x = x - getResources().getDimensionPixelSize(R.dimen.context_menu_width) + offset + offset; params.y = display.getHeight() - y - offset; break; case "top_left": case "top_vertical_left": params.gravity = Gravity.TOP | Gravity.LEFT; params.x = x; params.y = y - offset + statusBarHeight; break; case "top_right": case "top_vertical_right": params.gravity = Gravity.TOP | Gravity.LEFT; params.x = x - getResources().getDimensionPixelSize(R.dimen.context_menu_width) + offset + offset; params.y = y - offset + statusBarHeight; break; } } else { LocalBroadcastManager.getInstance(this) .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU")); int x = getIntent().getIntExtra("x", display.getWidth()); int y = getIntent().getIntExtra("y", display.getHeight()); int offset = getResources().getDimensionPixelSize(R.dimen.icon_size); switch (U.getTaskbarPosition(this)) { case "bottom_left": params.gravity = Gravity.BOTTOM | Gravity.LEFT; params.x = isStartButton ? 0 : x; params.y = offset; break; case "bottom_vertical_left": params.gravity = Gravity.BOTTOM | Gravity.LEFT; params.x = offset; params.y = display.getHeight() - y - (isStartButton ? 0 : offset); break; case "bottom_right": params.gravity = Gravity.BOTTOM | Gravity.RIGHT; params.x = display.getWidth() - x; params.y = offset; break; case "bottom_vertical_right": params.gravity = Gravity.BOTTOM | Gravity.RIGHT; params.x = offset; params.y = display.getHeight() - y - (isStartButton ? 0 : offset); break; case "top_left": params.gravity = Gravity.TOP | Gravity.LEFT; params.x = isStartButton ? 0 : x; params.y = offset; break; case "top_vertical_left": params.gravity = Gravity.TOP | Gravity.LEFT; params.x = offset; params.y = isStartButton ? 0 : y - statusBarHeight; break; case "top_right": params.gravity = Gravity.TOP | Gravity.RIGHT; params.x = display.getWidth() - x; params.y = offset; break; case "top_vertical_right": params.gravity = Gravity.TOP | Gravity.RIGHT; params.x = offset; params.y = isStartButton ? 0 : y - statusBarHeight; break; } } params.width = getResources().getDimensionPixelSize(R.dimen.context_menu_width); params.dimAmount = 0; getWindow().setAttributes(params); View view = findViewById(android.R.id.list); if (view != null) view.setPadding(0, 0, 0, 0); generateMenu(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("com.farmerbb.taskbar.START_MENU_APPEARING"); intentFilter.addAction("com.farmerbb.taskbar.DASHBOARD_APPEARING"); LocalBroadcastManager.getInstance(this).registerReceiver(finishReceiver, intentFilter); }
From source file:com.telenav.expandablepager.ExpandablePager.java
/** * Move the layout to the bottom of the screen in case it was not moved in the xml file *//*from ww w.j a v a 2s. c om*/ private void pinToBottom() { ViewGroup.LayoutParams params = getLayoutParams(); if (params != null) { if (params instanceof RelativeLayout.LayoutParams) { ((LayoutParams) params).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); } else if (params instanceof LinearLayout.LayoutParams) { ((LinearLayout.LayoutParams) params).gravity = Gravity.BOTTOM; } else if (params instanceof FrameLayout.LayoutParams) { ((FrameLayout.LayoutParams) params).gravity = Gravity.BOTTOM; } } }
From source file:com.github.baoti.pioneer.ui.common.image.chooser.ImageChooserFragment.java
private void setupDialog() { getDialog().setCanceledOnTouchOutside(true); getDialog().getWindow().setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM); getDialog().getWindow().setWindowAnimations(R.style.Animation_Window_SlideBottom); WindowManager.LayoutParams params = getDialog().getWindow().getAttributes(); // params.dimAmount = 0.5f; // params.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND; params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN; params.width = WindowManager.LayoutParams.MATCH_PARENT; params.height = WindowManager.LayoutParams.WRAP_CONTENT; getDialog().getWindow().setAttributes(params); }
From source file:com.jinzht.pro.view.RecyclerViewHeader.java
private void setupAlignment(RecyclerView recycler) { if (!mAlreadyAligned) { //setting alignment of header ViewGroup.LayoutParams currentParams = getLayoutParams(); FrameLayout.LayoutParams newHeaderParams; int width = ViewGroup.LayoutParams.WRAP_CONTENT; int height = ViewGroup.LayoutParams.WRAP_CONTENT; int gravity = (mReversed ? Gravity.BOTTOM : Gravity.TOP) | Gravity.CENTER_HORIZONTAL; if (currentParams != null) { newHeaderParams = new FrameLayout.LayoutParams(getLayoutParams()); //to copy all the margins newHeaderParams.width = width; newHeaderParams.height = height; newHeaderParams.gravity = gravity; } else {//w w w. j a va 2 s . c o m newHeaderParams = new FrameLayout.LayoutParams(width, height, gravity); } RecyclerViewHeader.this.setLayoutParams(newHeaderParams); //setting alignment of recycler FrameLayout newRootParent = new FrameLayout(recycler.getContext()); newRootParent.setLayoutParams(recycler.getLayoutParams()); ViewParent currentParent = recycler.getParent(); if (currentParent instanceof ViewGroup) { int indexWithinParent = ((ViewGroup) currentParent).indexOfChild(recycler); ((ViewGroup) currentParent).removeViewAt(indexWithinParent); recycler.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); newRootParent.addView(recycler); newRootParent.addView(RecyclerViewHeader.this); ((ViewGroup) currentParent).addView(newRootParent, indexWithinParent); } } }
From source file:com.lamcreations.scaffold.common.views.CollapsingToolbarTabLayout.java
private CollapsingTextHelper getCollapsingTextHelper() { if (mCollapsingTextHelper == null) { mCollapsingTextHelper = new CollapsingTextHelper(this); mCollapsingTextHelper.setCollapsedTextVerticalGravity(Gravity.CENTER_VERTICAL); mCollapsingTextHelper.setExpandedTextVerticalGravity(Gravity.BOTTOM); mCollapsingTextHelper//from w w w. jav a2 s .c o m .setTextSizeInterpolator(CollapsingTextHelper.AnimationUtils.DECELERATE_INTERPOLATOR); } return mCollapsingTextHelper; }
From source file:com.mixiaoxiao.mxxedgeeffect.widget.MxxPagerTitleStrip.java
public MxxPagerTitleStrip(Context context, AttributeSet attrs) { super(context, attrs); addView(mPrevText = new TextView(context)); addView(mCurrText = new TextView(context)); addView(mNextText = new TextView(context)); final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); final int textAppearance = a.getResourceId(0, 0); if (textAppearance != 0) { mPrevText.setTextAppearance(context, textAppearance); mCurrText.setTextAppearance(context, textAppearance); mNextText.setTextAppearance(context, textAppearance); }/*from ww w. j a va 2s .c om*/ final int textSize = a.getDimensionPixelSize(1, 0); if (textSize != 0) { setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); } if (a.hasValue(2)) { final int textColor = a.getColor(2, 0); mPrevText.setTextColor(textColor); mCurrText.setTextColor(textColor); mNextText.setTextColor(textColor); } mGravity = a.getInteger(3, Gravity.BOTTOM); a.recycle(); mTextColor = mCurrText.getTextColors().getDefaultColor(); setNonPrimaryAlpha(SIDE_ALPHA); mPrevText.setEllipsize(TruncateAt.END); mCurrText.setEllipsize(TruncateAt.END); mNextText.setEllipsize(TruncateAt.END); boolean allCaps = false; if (textAppearance != 0) { final TypedArray ta = context.obtainStyledAttributes(textAppearance, TEXT_ATTRS); allCaps = ta.getBoolean(0, false); ta.recycle(); } if (allCaps) { setSingleLineAllCaps(mPrevText); setSingleLineAllCaps(mCurrText); setSingleLineAllCaps(mNextText); } else { mPrevText.setSingleLine(); mCurrText.setSingleLine(); mNextText.setSingleLine(); } final float density = context.getResources().getDisplayMetrics().density; mScaledTextSpacing = (int) (TEXT_SPACING * density); mCircleIndicator = new CircleIndicator(context, attrs); addView(mCircleIndicator); }
From source file:android.support.transition.Slide.java
/** * Constructor using the default {@link Gravity#BOTTOM} * slide edge direction. */ public Slide() { setSlideEdge(Gravity.BOTTOM); }
From source file:com.klokisoft.mathdokuext.ui.ArchiveFragmentActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.archive_activity_fragment); // Create an adapter that when requested, will return a fragment // representing an object in the collection. // ViewPager and its adapters use support library fragments, so we must // use getSupportFragmentManager. mArchiveFragmentStatePagerAdapter = new ArchiveFragmentStatePagerAdapter(getSupportFragmentManager(), this); // Get preferences for displaying the filter. mShowStatusFilter = mMathDokuPreferences.isArchiveStatusFilterVisible(); mShowSizeFilter = mMathDokuPreferences.isArchiveSizeFilterVisible(); mArchiveFragmentStatePagerAdapter// w w w .j a va 2s.co m .setStatusFilter(mMathDokuPreferences.getArchiveStatusFilterLastValueUsed()); mArchiveFragmentStatePagerAdapter.setSizeFilter(mMathDokuPreferences.getArchiveSizeFilterLastValueUsed()); mActionBar = getActionBar(); if (mActionBar != null) { mActionBar.setDisplayHomeAsUpEnabled(true); mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); mActionBar.setTitle(getResources().getString(R.string.archive_action_bar_title)); mActionBar.setDisplayShowCustomEnabled(true); mActionBar.setCustomView(R.layout.archive_action_bar_custom); setStatusSpinner(); setSizeSpinner(); } // Set up the ViewPager, attaching the adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mArchiveFragmentStatePagerAdapter); // Set up the pager tab strip final PagerTabStrip pagerTabStrip = (PagerTabStrip) findViewById(R.id.pager_tab_strip); pagerTabStrip.setDrawFullUnderline(false); // This pager contains a maximum of 3 visible items. The selected tab // will always be displayed in the middle. Hide the tab indicator by // setting color identical to background color. PagerTabStripPainter pagerTabStripPainter = Painter.getInstance().getPagerTabStripPainter(); pagerTabStrip.setTabIndicatorColor(pagerTabStripPainter.getBackgroundColor()); pagerTabStrip.setBackgroundColor(pagerTabStripPainter.getBackgroundColor()); pagerTabStrip.setTextColor(pagerTabStripPainter.getTextColor()); pagerTabStrip.setTextSize(TypedValue.COMPLEX_UNIT_SP, getResources().getDimension(com.klokisoft.mathdokuext.R.dimen.text_size_default) / getResources().getDisplayMetrics().density); pagerTabStrip.setGravity(Gravity.BOTTOM); // Non primary items are semi transparent. pagerTabStrip.setNonPrimaryAlpha(0.75f); // In case a solving attempt has been specified in the bundle, this // solving attempt will be showed as selected grid as long as it does // meet the selection criteria of the filters. Intent intent = getIntent(); if (intent != null) { Bundle bundle = intent.getExtras(); if (bundle != null) { int solvingAttemptId = bundle.getInt(BUNDLE_KEY_SOLVING_ATTEMPT_ID); if (solvingAttemptId >= 0 && mArchiveFragmentStatePagerAdapter.getPositionOfGridId(solvingAttemptId) >= 0) { mMathDokuPreferences.setArchiveGridIdLastShowed(solvingAttemptId); } } } }
From source file:com.example.deii.trustone.SignUpActivity.java
private void showPicSelectDialog(final Context ctx) { dialog = new Dialog(ctx, R.style.DialogSlideAnim1); dialog.setContentView(R.layout.dialog_select_image); dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent); Window window = dialog.getWindow(); WindowManager.LayoutParams wlp = window.getAttributes(); wlp.gravity = Gravity.BOTTOM; wlp.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND; window.setAttributes(wlp);/*from ww w. j av a 2 s. c o m*/ TextView chooseFromGallery = (TextView) dialog.findViewById(R.id.text_fromGallery); chooseFromGallery.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { loadPermissions(Manifest.permission.READ_EXTERNAL_STORAGE, GALLERY_REQUEST); } else startGallery(); } }); TextView takeFromCamera = (TextView) dialog.findViewById(R.id.text_fromCamera); takeFromCamera.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) loadPermissions(Manifest.permission.CAMERA, CAMERA_REQUEST); else startCamera(); } }); TextView imgCancel = (TextView) dialog.findViewById(R.id.text_dialogClose); imgCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); }
From source file:kookmin.cs.sympathymusiz.VideoListDemoActivity.java
/** * Sets up the layout programatically for the three different states. Portrait, landscape or * fullscreen+landscape. This has to be done programmatically because we handle the orientation * changes ourselves in order to get fluent fullscreen transitions, so the xml layout resources * do not get reloaded./*from ww w . ja v a2 s. c o m*/ */ private void layout() { boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; //ArrayList<ArrayList<String>> list = (ArrayList<ArrayList<String>>) getIntent("exIntent""); listFragment.getView().setVisibility(isFullscreen ? View.GONE : View.VISIBLE); listFragment.setLabelVisibility(isPortrait); closeButton.setVisibility(isPortrait ? View.VISIBLE : View.GONE); if (isFullscreen) { videoBox.setTranslationY(0); // Reset any translation that was applied in portrait. setLayoutSize(videoFragment.getView(), MATCH_PARENT, MATCH_PARENT); setLayoutSizeAndGravity(videoBox, MATCH_PARENT, MATCH_PARENT, Gravity.TOP | Gravity.LEFT); } else if (isPortrait) { setLayoutSize(listFragment.getView(), MATCH_PARENT, MATCH_PARENT); setLayoutSize(videoFragment.getView(), MATCH_PARENT, WRAP_CONTENT); setLayoutSizeAndGravity(videoBox, MATCH_PARENT, WRAP_CONTENT, Gravity.BOTTOM); } else { videoBox.setTranslationY(0); // Reset any translation that was applied in portrait. int screenWidth = dpToPx(getResources().getConfiguration().screenWidthDp); setLayoutSize(listFragment.getView(), screenWidth / 4, MATCH_PARENT); int videoWidth = screenWidth - screenWidth / 4 - dpToPx(LANDSCAPE_VIDEO_PADDING_DP); setLayoutSize(videoFragment.getView(), videoWidth, WRAP_CONTENT); setLayoutSizeAndGravity(videoBox, videoWidth, WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL); } }