List of usage examples for android.view Gravity RIGHT
int RIGHT
To view the source code for android.view Gravity RIGHT.
Click Source Link
From source file:com.cooltechworks.views.ScratchTextView.java
private int[] getTextBounds(float scale) { int paddingLeft = getPaddingLeft(); int paddingTop = getPaddingTop(); int paddingRight = getPaddingRight(); int paddingBottom = getPaddingBottom(); int vwidth = getWidth(); int vheight = getHeight(); int centerX = vwidth / 2; int centerY = vheight / 2; TextPaint paint = getPaint();//w ww. jav a 2s. co m String text = getText().toString(); int[] dimens = getTextDimens(text, paint); int width = dimens[0]; int height = dimens[1]; int lines = getLineCount(); height = height * lines; width = width / lines; int left = 0; int top = 0; if (height > vheight) { height = vheight - (paddingBottom + paddingTop); } else { height = (int) (height * scale); } if (width > vwidth) { width = vwidth - (paddingLeft + paddingRight); } else { width = (int) (width * scale); } int gravity = getGravity(); //todo Gravity.START if ((gravity & Gravity.LEFT) == Gravity.LEFT) { left = paddingLeft; } //todo Gravity.END else if ((gravity & Gravity.RIGHT) == Gravity.RIGHT) { left = (vwidth - paddingRight) - width; } else if ((gravity & Gravity.CENTER_HORIZONTAL) == Gravity.CENTER_HORIZONTAL) { left = centerX - width / 2; } if ((gravity & Gravity.TOP) == Gravity.TOP) { top = paddingTop; } else if ((gravity & Gravity.BOTTOM) == Gravity.BOTTOM) { top = (vheight - paddingBottom) - height; } else if ((gravity & Gravity.CENTER_VERTICAL) == Gravity.CENTER_VERTICAL) { top = centerY - height / 2; } return new int[] { left, top, left + width, top + height }; }
From source file:com.example.view.astuetz.PagerSlidingTabStrip.java
@SuppressLint("NewApi") private void addIconTab(int position, int resId, String notification) { FrameLayout tabItemCon = new FrameLayout(getContext()); ImageView tab = new ImageView(getContext()); tab.setImageResource(resId);// w ww. ja v a 2 s. c o m tabItemCon.addView(tab); tabIconlist.put(position, tab); ImageView notiSymbol = new ImageView(getContext()); notiSymbol.setImageResource(R.drawable.badge_background); BadgeView noti = new BadgeView(getContext()); noti.setText(notification); tabItemCon.addView(noti); tabItemCon.addView(notiSymbol); if (notification != null && !notification.equals("")) { noti.setVisibility(View.VISIBLE); notiSymbol.setVisibility(View.GONE); } else if (notification != null && notification.equals("")) { noti.setVisibility(View.GONE); notiSymbol.setVisibility(View.VISIBLE); } else { notiSymbol.setVisibility(View.GONE); noti.setVisibility(View.GONE); } int notiSySize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics()); noti.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.TOP)); notiSymbol.setLayoutParams(new LayoutParams(notiSySize, notiSySize, Gravity.RIGHT | Gravity.TOP)); FrameLayout tabItem = new FrameLayout(getContext()); tabItem.addView(tabItemCon); tabItemCon.setLayoutParams( new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER)); addTab(position, tabItem); }
From source file:com.hippo.ehviewer.ui.MainActivity.java
@Override protected void onCreate2(@Nullable Bundle savedInstanceState) { setContentView(R.layout.activity_main); mDrawerLayout = (DrawerLayout) ViewUtils.$$(this, R.id.draw_view); mNavView = (NavigationView) ViewUtils.$$(this, R.id.nav_view); mRightDrawer = (FrameLayout) ViewUtils.$$(this, R.id.right_drawer); View headerLayout = mNavView.getHeaderView(0); mAvatar = (LoadImageView) ViewUtils.$$(headerLayout, R.id.avatar); mDisplayName = (TextView) ViewUtils.$$(headerLayout, R.id.display_name); // Pre-L need shadow drawable if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_left, Gravity.LEFT); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_right, Gravity.RIGHT); }//from w ww .ja v a 2 s.com updateProfile(); if (mNavView != null) { mNavView.setNavigationItemSelectedListener(this); } if (savedInstanceState == null) { onInit(); CommonOperations.checkUpdate(this, false); } else { onRestore(savedInstanceState); } }
From source file:com.hippo.widget.slidingdrawerlayout.SlidingDrawerLayout.java
public boolean isDrawerOpen(int gravity) { if (gravity == Gravity.LEFT) return isDrawerOpen(mLeftDrawer); else if (gravity == Gravity.RIGHT) return isDrawerOpen(mRightDrawer); else//from w ww .j a v a 2 s . c o m throw new IllegalArgumentException("gravity must be Gravity.LEFT or Gravity.RIGHT"); }
From source file:com.gh4a.BaseActivity.java
protected void updateRightNavigationDrawer() { int[] drawerMenuResIds = getRightNavigationDrawerMenuResources(); if (drawerMenuResIds != null) { mRightDrawer.getMenu().clear();//from www.j av a 2 s . c om for (int id : drawerMenuResIds) { mRightDrawer.inflateMenu(id); } mRightDrawer.setNavigationItemSelectedListener(this); onPrepareRightNavigationDrawerMenu(mRightDrawer.getMenu()); mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT); } else { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT); } }
From source file:com.aidy.bottomdrawerlayout.DrawerLayout.java
/** * Set a simple drawable used for the left or right shadow. The drawable * provided must have a nonzero intrinsic width. * //from w w w. j ava2s . co m * @param shadowDrawable * Shadow drawable to use at the edge of a drawer * @param gravity * Which drawer the shadow should apply to */ public void setDrawerShadow(Drawable shadowDrawable, int gravity) { /* * TODO Someone someday might want to set more complex drawables here. * They're probably nuts, but we might want to consider registering * callbacks, setting states, etc. properly. */ final int absGravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this)); if ((absGravity & Gravity.LEFT) == Gravity.LEFT) { mShadowLeft = shadowDrawable; invalidate(); } if ((absGravity & Gravity.RIGHT) == Gravity.RIGHT) { mShadowRight = shadowDrawable; invalidate(); } }
From source file:com.hippo.drawerlayout.DrawerLayout.java
public void closeDrawer(int gravity) { if (gravity == Gravity.LEFT) { closeDrawer(mLeftDrawer);// w ww .j a v a 2 s. c o m } else if (gravity == Gravity.RIGHT) { closeDrawer(mRightDrawer); } }
From source file:com.mattprecious.prioritysms.activity.ProfileListActivity.java
private void configureActionBar() { actionBarSwitch = new Switch(this, null, R.attr.switchStyleAb); actionBarSwitch.setChecked(preferences.getBoolean(getString(R.string.pref_key_enabled), false)); actionBarSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override/*w ww. j a v a 2s. c o m*/ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { preferences.edit().putBoolean(getString(R.string.pref_key_enabled), isChecked).commit(); } }); final int padding = getResources().getDimensionPixelSize(R.dimen.action_bar_switch_padding); actionBarSwitch.setPadding(0, 0, padding, 0); getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM); getSupportActionBar().setCustomView(actionBarSwitch, new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.RIGHT)); }
From source file:ca.co.rufus.androidboilerplate.ui.DebugDrawerLayout.java
public DebugDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); final float density = getResources().getDisplayMetrics().density; mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * density + 0.5f); final float minVel = MIN_FLING_VELOCITY * density; mLeftCallback = new ViewDragCallback(Gravity.LEFT); mRightCallback = new ViewDragCallback(Gravity.RIGHT); mLeftDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mLeftCallback); mLeftDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT); mLeftDragger.setMinVelocity(minVel); mLeftCallback.setDragger(mLeftDragger); mRightDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mRightCallback); mRightDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_RIGHT); mRightDragger.setMinVelocity(minVel); mRightCallback.setDragger(mRightDragger); // So that we can catch the back button setFocusableInTouchMode(true);/*from w w w .ja v a2 s . c o m*/ ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate()); ViewGroupCompat.setMotionEventSplittingEnabled(this, false); if (ViewCompat.getFitsSystemWindows(this)) { IMPL.configureApplyInsets(this); mStatusBarBackground = IMPL.getDefaultStatusBarBackground(context); } }