Java Code Examples for android.view.Gravity#CENTER_VERTICAL
The following examples show how to use
android.view.Gravity#CENTER_VERTICAL .
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: CollapsingToolbarLayoutManager.java From react-native-collapsing-toolbar with MIT License | 6 votes |
private int getGravity(String gravity) { switch (gravity) { case "CENTER": return Gravity.CENTER; case "CENTER_VERTICAL": return Gravity.CENTER_VERTICAL; case "TOP": return Gravity.TOP; case "LEFT": return Gravity.LEFT; case "RIGHT": return Gravity.RIGHT; case "BOTTOM": return Gravity.BOTTOM; case "START": return Gravity.START; case "END": return Gravity.END; default: return Gravity.CENTER_VERTICAL; } }
Example 2
Source File: MyPieChartView.java From kAndroid with Apache License 2.0 | 6 votes |
private void addHorizontal() { mRecyclerView = new RecyclerView(mContext); mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext)); mRecyclerView.setNestedScrollingEnabled(false); if (adapter == null) { adapter = new PicChartAdapter(mContext, mData); mRecyclerView.setAdapter(adapter); } else { adapter.notifyDataSetChanged(); } RelativeLayout relativeLayout = new RelativeLayout(mContext); LayoutParams params = new LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL; relativeLayout.setLayoutParams(params); RelativeLayout.LayoutParams p2 = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, (int) (mBaseHeight - 2 * raduis - 20)); relativeLayout.addView(mRecyclerView, p2); addView(relativeLayout); }
Example 3
Source File: RouteBaiduBusActivity.java From BmapLite with GNU General Public License v3.0 | 5 votes |
private void configMap() { ConfigInteracter configInteracter = new ConfigInteracter(this); mBaiduMap.getUiSettings().setZoomGesturesEnabled(configInteracter.isZoomGesturesEnabled()); mBaiduMap.getUiSettings().setOverlookingGesturesEnabled(configInteracter.isOverlookEnable()); mBaiduMap.getUiSettings().setRotateGesturesEnabled(configInteracter.isRotateEnable()); mMapView.showScaleControl(configInteracter.isShowScaleControl()); mBaiduMap.showMapPoi(configInteracter.isMapPoiEnable()); mBaiduMap.setTrafficEnabled(configInteracter.isTrafficEnable()); if (configInteracter.getNightMode() == 2) { MapView.setMapCustomEnable(true); } else { MapView.setMapCustomEnable(false); } mMapView.showZoomControls(false); mBaiduMap.setMaxAndMinZoomLevel(20f, 3f); CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); if (configInteracter.getZoomControlsPosition()) { params.rightMargin = AppUtils.dip2Px(this, 10); params.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT; } else { params.leftMargin = AppUtils.dip2Px(this, 10); params.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT; } mCardZoom.setLayoutParams(params); // if (configInteracter.getZoomControlsPosition()) { // mMapView.setZoomControlsPosition(new Point(mMapView.getWidth() - 150, mMapView.getHeight() / 2)); // } else { // mMapView.setZoomControlsPosition(new Point(20, mMapView.getHeight() / 2)); // } }
Example 4
Source File: TipView.java From Android-TipView with Apache License 2.0 | 5 votes |
private TextView newTextView(){ TextView textView = new TextView(getContext()); FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.CENTER_VERTICAL); textView.setLayoutParams(lp); textView.setCompoundDrawablePadding(10); textView.setGravity(Gravity.CENTER_VERTICAL); textView.setLines(2); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setTextColor(Color.parseColor(DEFAULT_TEXT_COLOR)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_TEXT_SIZE); return textView; }
Example 5
Source File: FloatingActionButton.java From android-open-project-demo with Apache License 2.0 | 5 votes |
/** * Sets the position of the button by calculating its Gravity from the position parameter * @param position one of 8 specified positions. * @param layoutParams */ public void setPosition(int position, FrameLayout.LayoutParams layoutParams) { int gravity; switch(position) { case POSITION_TOP_CENTER: gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; break; case POSITION_TOP_RIGHT: gravity = Gravity.TOP | Gravity.RIGHT; break; case POSITION_RIGHT_CENTER: gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL; break; case POSITION_BOTTOM_CENTER: gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; break; case POSITION_BOTTOM_LEFT: gravity = Gravity.BOTTOM | Gravity.LEFT; break; case POSITION_LEFT_CENTER: gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL; break; case POSITION_TOP_LEFT: gravity = Gravity.TOP | Gravity.LEFT; break; case POSITION_BOTTOM_RIGHT: default: gravity = Gravity.BOTTOM | Gravity.RIGHT; break; } layoutParams.gravity = gravity; setLayoutParams(layoutParams); }
Example 6
Source File: ImageScannerDialogLayout.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 5 votes |
public void initCancelView() { mCancelView = new TextView(mContext); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); params.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT; params.rightMargin = VenvyUIUtil.dip2px(mContext, 16); mCancelView.setLayoutParams(params); mCancelView.setTextColor(Color.WHITE); mCancelView.setGravity(Gravity.CENTER); mCancelView.setText("取消"); mCancelView.setTextSize(18); mCancelView.setVisibility(GONE); mCancelView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { removeAllViews(); if (imageModel != null) { imageModel.onDestroy(); imageModel = null; } mGridView = null; imageItemAdapter = null; mListView = null; if (imageFolderModel != null) { imageFolderModel.onDestroy(); imageFolderModel = null; } imageFloderAdapter = null; if (mDismissDialogListener != null) { mDismissDialogListener.onClick(null); } } }); }
Example 7
Source File: FriendListItem.java From MyHearts with Apache License 2.0 | 5 votes |
public FriendListItem(Context context, float ratio) { super(context); int itemPadding = (int) (ratio * DESIGN_ITEM_PADDING); setPadding(itemPadding, 0, itemPadding, 0); setMinimumHeight((int) (ratio * DESIGN_ITEM_HEIGHT)); setBackgroundColor(0xffffffff); ivCheck = new ImageView(context); LayoutParams lp = new LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER_VERTICAL; addView(ivCheck, lp); aivIcon = new AsyncImageView(context); int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH); lp = new LayoutParams(avatarWidth, avatarWidth); lp.gravity = Gravity.CENTER_VERTICAL; int avatarMargin = (int) (ratio * DESIGN_AVATAR_PADDING); lp.setMargins(avatarMargin, 0, avatarMargin, 0); addView(aivIcon, lp); tvName = new TextView(context); tvName.setTextColor(0xff000000); tvName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); tvName.setSingleLine(); lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER_VERTICAL; lp.weight = 1; addView(tvName, lp); int resId = R.getBitmapRes(context, "ssdk_oks_classic_check_checked"); if (resId > 0) { bmChd = BitmapFactory.decodeResource(context.getResources(), resId); } resId = R.getBitmapRes(getContext(), "ssdk_oks_classic_check_default"); if (resId > 0) { bmUnch = BitmapFactory.decodeResource(context.getResources(), resId); } }
Example 8
Source File: LightAndVolumeController.java From XposedNavigationBar with GNU General Public License v3.0 | 5 votes |
private ViewGroup getPanel(Context context, int type) { final ViewGroup mViewGroup = new LinearLayout(context); LinearLayout.LayoutParams btnParam = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); // btnParam.weight = 1; btnParam.gravity = Gravity.CENTER_VERTICAL; LinearLayout.LayoutParams seekBarParam = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); seekBarParam.weight = 1; seekBarParam.gravity = Gravity.CENTER; ImageButton btnBack = new ImageButton(context); btnBack.setImageBitmap(backBitmap); btnBack.setScaleType(ImageView.ScaleType.FIT_CENTER); btnBack.setBackgroundColor(Color.alpha(255)); SeekBar seekBar = getSeekBar(context, type); ImageButton btnFunc = new ImageButton(context); btnFunc.setImageBitmap(funcBitmap); btnFunc.setScaleType(ImageView.ScaleType.FIT_CENTER); btnFunc.setBackgroundColor(Color.alpha(255)); mViewGroup.addView(btnBack, btnParam); mViewGroup.addView(seekBar, seekBarParam); mViewGroup.addView(btnFunc, btnParam); final WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); mViewGroup.setBackgroundColor(Color.BLACK); btnBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { wm.removeView(mViewGroup); } }); return mViewGroup; }
Example 9
Source File: AllAppsBackgroundDrawable.java From Trebuchet with GNU General Public License v3.0 | 5 votes |
public void updateBounds(Rect bounds) { int width = mImage.getIntrinsicWidth(); int height = mImage.getIntrinsicHeight(); int left = bounds.left + (int) (mXPercent * bounds.width()); int top = bounds.top + (int) (mYPercent * bounds.height()); if ((mGravity & Gravity.CENTER_HORIZONTAL) == Gravity.CENTER_HORIZONTAL) { left -= (width / 2); } if ((mGravity & Gravity.CENTER_VERTICAL) == Gravity.CENTER_VERTICAL) { top -= (height / 2); } mImage.setBounds(left, top, left + width, top + height); }
Example 10
Source File: RichAppLinkSidePanelActivity.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); List<Channel> channels = ModelUtils.getChannels(getContentResolver()); Channel appLinkChannel = null; String displayNumber = getIntent().getStringExtra(RichFeedUtil.EXTRA_DISPLAY_NUMBER); if (displayNumber != null) { for (Channel channel : channels) { if (displayNumber.equals(channel.getDisplayNumber())) { appLinkChannel = channel; break; } } } // Sets the size and position of dialog activity. WindowManager.LayoutParams layoutParams = getWindow().getAttributes(); layoutParams.gravity = Gravity.END | Gravity.CENTER_VERTICAL; layoutParams.width = getResources().getDimensionPixelSize(R.dimen.side_panel_width); layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT; getWindow().setAttributes(layoutParams); setContentView(R.layout.rich_app_link_side_panel); if (appLinkChannel != null && appLinkChannel.getAppLinkColor() != 0) { TextView titleView = (TextView) findViewById(R.id.title); titleView.setBackgroundColor(appLinkChannel.getAppLinkColor()); } mAppLinkMenuList = (VerticalGridView) findViewById(R.id.list); mAppLinkMenuList.setAdapter(new AppLinkMenuAdapter()); }
Example 11
Source File: Banner.java From HomeApplianceMall with MIT License | 5 votes |
public Banner setIndicatorGravity(int type) { switch (type) { case BannerConfig.LEFT: this.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL; break; case BannerConfig.CENTER: this.gravity = Gravity.CENTER; break; case BannerConfig.RIGHT: this.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL; break; } return this; }
Example 12
Source File: ActionMenuView.java From zhangshangwuda with Apache License 2.0 | 5 votes |
@Override protected LayoutParams generateDefaultLayoutParams() { LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER_VERTICAL; return params; }
Example 13
Source File: CommentListDialog.java From xposed-aweme with Apache License 2.0 | 4 votes |
@Override protected View createView(LayoutInflater inflater, ViewGroup container) { // 不显示默认标题 getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE); mCommonFrameLayout = new CommonFrameLayout(getContext()); mToolbar = mCommonFrameLayout.getTitleView(); mMoreButton = mToolbar.addMoreImageButton(); LinearLayout layout = LayoutUtil.newCommonLayout(getContext()); FrameLayout headLayout = new FrameLayout(getContext()); headLayout.setLayoutParams(LayoutUtil.newFrameLayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT)); TextView tvTips = new TextView(getContext()); tvTips.setTextColor(0xffafafaf); tvTips.setTextSize(10f); tvTips.setText("提示:单击编辑左滑可删除"); mAddCommonButton = new Button(getContext()); mAddCommonButton.setText("添加"); mAddCommonButton.setTextSize(14f); mAddCommonButton.setTextColor(0xFFF93F25); mAddCommonButton.setBackgroundColor(0x00000000); FrameLayout.LayoutParams tipsParams = LayoutUtil.newWrapFrameLayoutParams(); tipsParams.leftMargin = DisplayUtil.dip2px(getContext(), 15f); tipsParams.gravity = Gravity.CENTER_VERTICAL; FrameLayout.LayoutParams params = LayoutUtil.newFrameLayoutParams( DisplayUtil.dip2px(getContext(), 70f), DisplayUtil.dip2px(getContext(), 40f)); params.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL; headLayout.addView(tvTips, tipsParams); headLayout.addView(mAddCommonButton, params); mSwipeMenuListView = new SwipeMenuListView(getContext()); mSwipeMenuListView.setCacheColorHint(0x00000000); mSwipeMenuListView.setDividerHeight(0); mSwipeMenuListView.setMenuCreator(newMenuCreator()); mSwipeMenuListView.setCloseInterpolator(new BounceInterpolator()); mSwipeMenuListView.setLayoutParams(LayoutUtil.newMatchLinearLayoutParams()); layout.addView(headLayout); layout.addView(mSwipeMenuListView); mCommonFrameLayout.setContent(layout); return mCommonFrameLayout; }
Example 14
Source File: CenterChildGravity.java From ChipsLayoutManager with Apache License 2.0 | 4 votes |
@Override @SpanLayoutChildGravity public int getItemGravity(int position) { return Gravity.CENTER_VERTICAL; }
Example 15
Source File: TopRightWeightedLayout.java From Camera2 with Apache License 2.0 | 4 votes |
/** * Swap gravity: * left for bottom * right for top * center horizontal for center vertical * etc * <p> * also swap left|right padding for bottom|top */ private void fixGravityAndPadding(int direction) { for (int i = 0; i < getChildCount(); i++) { // gravity swap View v = getChildAt(i); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) v.getLayoutParams(); int gravity = layoutParams.gravity; if (direction == LinearLayout.VERTICAL) { if ((gravity & Gravity.LEFT) != 0) { // if gravity left is set . . . gravity &= ~Gravity.LEFT; // unset left gravity |= Gravity.BOTTOM; // and set bottom } } else { if ((gravity & Gravity.BOTTOM) != 0) { // etc gravity &= ~Gravity.BOTTOM; gravity |= Gravity.LEFT; } } if (direction == LinearLayout.VERTICAL) { if ((gravity & Gravity.RIGHT) != 0) { gravity &= ~Gravity.RIGHT; gravity |= Gravity.TOP; } } else { if ((gravity & Gravity.TOP) != 0) { gravity &= ~Gravity.TOP; gravity |= Gravity.RIGHT; } } // don't mess with children that are centered in both directions if ((gravity & Gravity.CENTER) != Gravity.CENTER) { if (direction == LinearLayout.VERTICAL) { if ((gravity & Gravity.CENTER_VERTICAL) != 0) { gravity &= ~Gravity.CENTER_VERTICAL; gravity |= Gravity.CENTER_HORIZONTAL; } } else { if ((gravity & Gravity.CENTER_HORIZONTAL) != 0) { gravity &= ~Gravity.CENTER_HORIZONTAL; gravity |= Gravity.CENTER_VERTICAL; } } } layoutParams.gravity = gravity; // padding swap int paddingLeft = v.getPaddingLeft(); int paddingTop = v.getPaddingTop(); int paddingRight = v.getPaddingRight(); int paddingBottom = v.getPaddingBottom(); v.setPadding(paddingBottom, paddingRight, paddingTop, paddingLeft); } }
Example 16
Source File: CoordinatorLayout.java From ticdesign with Apache License 2.0 | 4 votes |
/** * Lay out a child view with respect to a keyline. * * <p>The keyline represents a horizontal offset from the unpadded starting edge of * the CoordinatorLayout. The child's gravity will affect how it is positioned with * respect to the keyline.</p> * * @param child child to lay out * @param keyline offset from the starting edge in pixels of the keyline to align with * @param layoutDirection ViewCompat constant for layout direction */ private void layoutChildWithKeyline(View child, int keyline, int layoutDirection) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); final int absGravity = GravityCompat.getAbsoluteGravity( resolveKeylineGravity(lp.gravity), layoutDirection); final int hgrav = absGravity & Gravity.HORIZONTAL_GRAVITY_MASK; final int vgrav = absGravity & Gravity.VERTICAL_GRAVITY_MASK; final int width = getWidth(); final int height = getHeight(); final int childWidth = child.getMeasuredWidth(); final int childHeight = child.getMeasuredHeight(); if (layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL) { keyline = width - keyline; } int left = getKeyline(keyline) - childWidth; int top = 0; switch (hgrav) { default: case Gravity.LEFT: // Nothing to do. break; case Gravity.RIGHT: left += childWidth; break; case Gravity.CENTER_HORIZONTAL: left += childWidth / 2; break; } switch (vgrav) { default: case Gravity.TOP: // Do nothing, we're already in position. break; case Gravity.BOTTOM: top += childHeight; break; case Gravity.CENTER_VERTICAL: top += childHeight / 2; break; } // Obey margins and padding left = Math.max(getPaddingLeft() + lp.leftMargin, Math.min(left, width - getPaddingRight() - childWidth - lp.rightMargin)); top = Math.max(getPaddingTop() + lp.topMargin, Math.min(top, height - getPaddingBottom() - childHeight - lp.bottomMargin)); child.layout(left, top, left + childWidth, top + childHeight); }
Example 17
Source File: FollowListPage.java From BigApp_WordPress_Android with Apache License 2.0 | 4 votes |
public View getView(int position, View convertView, ViewGroup parent) { FollowListItem item = null; boolean simpleMode = "FacebookMessenger".equals(platform.getName()); if (convertView == null) { LinearLayout llItem = new LinearLayout(parent.getContext()); item = new FollowListItem(); llItem.setTag(item); convertView = llItem; int dp_52 = com.mob.tools.utils.R.dipToPx(getContext(), 52); int dp_10 = com.mob.tools.utils.R.dipToPx(parent.getContext(), 10); int dp_5 = com.mob.tools.utils.R.dipToPx(parent.getContext(), 5); if(!simpleMode) { item.aivIcon = new AsyncImageView(getContext()); LayoutParams lpIcon = new LayoutParams(dp_52, dp_52); lpIcon.gravity = Gravity.CENTER_VERTICAL; lpIcon.setMargins(dp_10, dp_5, dp_10, dp_5); item.aivIcon.setLayoutParams(lpIcon); llItem.addView(item.aivIcon); } LinearLayout llText = new LinearLayout(parent.getContext()); llText.setPadding(0, dp_10, dp_10, dp_10); llText.setOrientation(LinearLayout.VERTICAL); LayoutParams lpText = new LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lpText.gravity = Gravity.CENTER_VERTICAL; lpText.weight = 1; llText.setLayoutParams(lpText); llItem.addView(llText); item.tvName = new TextView(parent.getContext()); item.tvName.setTextColor(0xff000000); item.tvName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); item.tvName.setSingleLine(); if(simpleMode) { item.tvName.setPadding(dp_10, 0, 0, 0); } llText.addView(item.tvName); if(!simpleMode) { item.tvSign = new TextView(parent.getContext()); item.tvSign.setTextColor(0x7f000000); item.tvSign.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); item.tvSign.setSingleLine(); llText.addView(item.tvSign); } item.ivCheck = new ImageView(parent.getContext()); item.ivCheck.setPadding(0, 0, dp_10, 0); LayoutParams lpCheck = new LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lpCheck.gravity = Gravity.CENTER_VERTICAL; item.ivCheck.setLayoutParams(lpCheck); llItem.addView(item.ivCheck); } else { item = (FollowListItem) convertView.getTag(); } Following following = getItem(position); item.tvName.setText(following.screenName); if(!simpleMode) { item.tvSign.setText(following.description); } item.ivCheck.setImageBitmap(following.checked ? bmChd : bmUnch); if(!simpleMode) { if (isFling()) { Bitmap bm = BitmapProcessor.getBitmapFromCache(following.icon); if (bm != null && !bm.isRecycled()) { item.aivIcon.setImageBitmap(bm); } else { item.aivIcon.execute(null, 0); } } else { item.aivIcon.execute(following.icon,0); } } if (position == getCount() - 1) { next(); } return convertView; }
Example 18
Source File: AbstractEditComponent.java From weex-uikit with MIT License | 4 votes |
protected int getVerticalGravity(){ return Gravity.CENTER_VERTICAL; }
Example 19
Source File: DrawableRatingBar.java From ProjectX with Apache License 2.0 | 4 votes |
@SuppressLint("RtlHardcoded") private void getOffset() { if (!tReGetOffset) return; tReGetOffset = false; final int measuredWidth = getMeasuredWidth(); final int measuredHeight = getMeasuredHeight(); final int paddingStart = Compat.getPaddingStart(this); final int paddingTop = getPaddingTop(); final int paddingEnd = Compat.getPaddingEnd(this); final int paddingBottom = getPaddingBottom(); final int itemWidth = drawableWidth * mMax + mDrawablePadding * (mMax - 1); switch (mGravity) { default: case Compat.START: case Gravity.LEFT: case Gravity.TOP: case Compat.START | Gravity.TOP: case Gravity.LEFT | Gravity.TOP: xOffset = paddingStart; yOffset = paddingTop; break; case Gravity.CENTER_HORIZONTAL: case Gravity.CENTER_HORIZONTAL | Gravity.TOP: xOffset = measuredWidth * 0.5f - itemWidth * 0.5f; yOffset = paddingTop; break; case Compat.END: case Gravity.RIGHT: case Compat.END | Gravity.TOP: case Gravity.RIGHT | Gravity.TOP: xOffset = measuredWidth - paddingEnd - itemWidth; yOffset = paddingTop; break; case Gravity.CENTER_VERTICAL: case Gravity.CENTER_VERTICAL | Compat.START: case Gravity.CENTER_VERTICAL | Gravity.LEFT: xOffset = paddingStart; yOffset = measuredHeight * 0.5f - drawableHeight * 0.5f; break; case Gravity.CENTER: xOffset = measuredWidth * 0.5f - itemWidth * 0.5f; yOffset = measuredHeight * 0.5f - drawableHeight * 0.5f; break; case Gravity.CENTER_VERTICAL | Compat.END: case Gravity.CENTER_VERTICAL | Gravity.RIGHT: xOffset = measuredWidth - paddingEnd - itemWidth; yOffset = measuredHeight * 0.5f - drawableHeight * 0.5f; break; case Gravity.BOTTOM: case Gravity.BOTTOM | Compat.START: case Gravity.BOTTOM | Gravity.LEFT: xOffset = paddingStart; yOffset = measuredHeight - paddingBottom - drawableHeight; break; case Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL: xOffset = measuredWidth * 0.5f - itemWidth * 0.5f; yOffset = measuredHeight - paddingBottom - drawableHeight; break; case Gravity.BOTTOM | Compat.END: case Gravity.BOTTOM | Gravity.RIGHT: xOffset = measuredWidth - paddingEnd - itemWidth; yOffset = measuredHeight - paddingBottom - drawableHeight; break; } }
Example 20
Source File: NotFullScreenTouchDisableFloatWindow.java From FloatWindow with Apache License 2.0 | 3 votes |
@Override public void create() { super.create(); mViewMode = WRAP_CONTENT_NOT_TOUCHABLE; mGravity = Gravity.CENTER_VERTICAL | Gravity.START; inflate(R.layout.main_layout_float_not_full_screen_touch_disable); }