List of usage examples for android.view Gravity START
int START
To view the source code for android.view Gravity START.
Click Source Link
From source file:io.github.douglasjunior.androidSimpleTooltip.SimpleTooltip.java
private PointF calculePopupLocation() { PointF location = new PointF(); final RectF anchorRect = calculeAnchorRect(); final PointF anchorCenter = new PointF(anchorRect.centerX(), anchorRect.centerY()); switch (mGravity) { case Gravity.START: location.x = anchorRect.left - mPopupWindow.getContentView().getWidth() - mMargin; location.y = anchorCenter.y - mPopupWindow.getContentView().getHeight() / 2f; break;/* w w w . ja va 2 s. co m*/ case Gravity.END: location.x = anchorRect.right + mMargin; location.y = anchorCenter.y - mPopupWindow.getContentView().getHeight() / 2f; break; case Gravity.TOP: location.x = anchorCenter.x - mPopupWindow.getContentView().getWidth() / 2f; location.y = anchorRect.top - mPopupWindow.getContentView().getHeight() - mMargin; break; case Gravity.BOTTOM: location.x = anchorCenter.x - mPopupWindow.getContentView().getWidth() / 2f; location.y = anchorRect.bottom + mMargin; break; default: throw new IllegalArgumentException("Gravity must have be START, END, TOP or BOTTOM."); } return location; }
From source file:com.quran.labs.androidquran.widgets.spinner.SpinnerCompat.java
/** * Construct a new spinner with the given context's theme, the supplied attribute set, and * default style. <code>mode</code> may be one of {@link #MODE_DIALOG} or {@link #MODE_DROPDOWN} * and determines how the user will select choices from the spinner. * * @param context The Context the view is running in, through which it can access the current * theme, resources, etc. * @param attrs The attributes of the XML tag that is inflating the view. * @param defStyle The default style to apply to this view. If 0, no style will be applied * (beyond what is included in the theme). This may either be an attribute * resource, whose value will be retrieved from the current theme, or an * explicit style resource. * @param mode Constant describing how the user will select choices from the spinner. * @see #MODE_DIALOG/*from w w w . j a va2s . c o m*/ * @see #MODE_DROPDOWN */ public SpinnerCompat(Context context, AttributeSet attrs, int defStyle, int mode) { super(context, attrs, defStyle); TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.Spinner, defStyle, 0); // Need to reset this for tinting purposes // used to be read from R.styleable.Spinner_android_background setBackgroundResource(R.drawable.spinner_mtrl_am_alpha); if (mode == MODE_THEME) { // used to be read from R.styleable.Spinner_spinnerMode mode = MODE_DROPDOWN; } switch (mode) { case MODE_DIALOG: { mPopup = new DialogPopup(); break; } case MODE_DROPDOWN: { final DropdownPopup popup = new DropdownPopup(context, attrs, defStyle); mDropDownWidth = ViewGroup.LayoutParams.WRAP_CONTENT; //popup.setBackgroundDrawable( // a.getDrawable(R.styleable.Spinner_android_popupBackground)); popup.setBackgroundDrawable(getResources().getDrawable(R.drawable.popup_background_material)); mPopup = popup; mForwardingListener = new ListPopupWindow.ForwardingListener(this) { @Override public ListPopupWindow getPopup() { return popup; } @Override public boolean onForwardingStarted() { if (!mPopup.isShowing()) { mPopup.show(); } return true; } }; break; } } // used to be read from R.styleable.Spinner_android_gravity mGravity = Gravity.START | Gravity.CENTER_VERTICAL; // used to be read from R.styleable.Spinner_disableChildrenWhenDisabled mDisableChildrenWhenDisabled = true; a.recycle(); // Base constructor can call setAdapter before we initialize mPopup. // Finish setting things up if this happened. if (mTempAdapter != null) { mPopup.setAdapter(mTempAdapter); mTempAdapter = null; } }
From source file:com.alburivan.slickform.tooltip.SimpleTooltip.java
private PointF calculePopupLocation() { PointF location = new PointF(); final RectF anchorRect = SimpleTooltipUtils.calculeRectInWindow(mAnchorView); final PointF anchorCenter = new PointF(anchorRect.centerX(), anchorRect.centerY()); switch (mGravity) { case Gravity.START: location.x = anchorRect.left - mPopupWindow.getContentView().getWidth() - mMargin; location.y = anchorCenter.y - mPopupWindow.getContentView().getHeight() / 2f; break;/*from ww w. ja v a 2 s . c o m*/ case Gravity.END: location.x = anchorRect.right + mMargin; location.y = anchorCenter.y - mPopupWindow.getContentView().getHeight() / 2f; break; case Gravity.TOP: location.x = anchorCenter.x - mPopupWindow.getContentView().getWidth() / 2f; location.y = anchorRect.top - mPopupWindow.getContentView().getHeight() - mMargin; break; case Gravity.BOTTOM: location.x = anchorCenter.x - mPopupWindow.getContentView().getWidth() / 2f; location.y = anchorRect.bottom + mMargin; break; default: throw new IllegalArgumentException("Gravity must have be START, END, TOP or BOTTOM."); } return location; }
From source file:com.android.settingslib.drawer.SettingsDrawerActivity.java
/** * xinsi * */ public void openDrawer() { if (mDrawerLayout != null) { mDrawerLayout.openDrawer(Gravity.START); } }
From source file:ca.zadrox.dota2esportticker.ui.BaseActivity.java
private void setupNavDrawer() { int selfItem = getSelfNavDrawerItem(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); if (mDrawerLayout == null) { return;//w w w. ja v a 2 s.c o m } mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.theme_primary_dark)); ScrimInsetsScrollView navDrawer = (ScrimInsetsScrollView) mDrawerLayout.findViewById(R.id.navdrawer); if (selfItem == NAVDRAWER_ITEM_INVALID) { if (navDrawer != null) { ((ViewGroup) navDrawer.getParent()).removeView(navDrawer); } mDrawerLayout = null; return; } 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; } 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(); // When the user runs the app for the first time, we want to land them with the // navigation drawer open. But just the first time. if (!PrefUtils.isWelcomeDone(this)) { // first run of the app starts with the nav drawer open PrefUtils.markWelcomeDone(this); mDrawerLayout.openDrawer(Gravity.START); this.startService( new Intent(UpdateMatchService.ACTION_UPDATE_MATCHES, null, this, UpdateMatchService.class)); } if (TimeUtils.getUTCTime() - PrefUtils.lastMatchUpdate(this) > 60000 * 60 * 12) { this.startService(new Intent(UpdateMatchService.ACTION_SCHEDULE_AUTO_UPDATE, null, this, UpdateMatchService.class)); } }
From source file:de.aw.monma.mainscreen.ActivityMainScreen.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Intent intent;//from ww w . j av a 2 s . c o m boolean consumed; mDrawerLayout.closeDrawer(Gravity.START, false); switch (item.getItemId()) { case R.id.menu_item_hbci_ums_vorhanden: item.setVisible(false); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.edit().putBoolean(getString(R.string.pref_OnlineUms), false).apply(); intent = new Intent(this, ActivityHBCIActions.class); intent.putExtra(ACTION, (Parcelable) Action.ShowNeueOnlineUmsaetze); startActivity(intent); consumed = true; break; case R.id.menu_item_Ertraege: intent = new Intent(this, ActivityActions.class); intent.putExtra(ACTION, (Parcelable) Action.EditErtraege); startActivity(intent); consumed = true; break; case R.id.awlib_menu_item_hilfe: intent = new Intent(this, AWWebViewActivity.class); intent.putExtra(ID, "hilfe_finanzuebersicht.html"); startActivity(intent); consumed = true; break; case R.id.menu_item_show_AllBuchungRegelm: intent = new Intent(this, ActivityCash.class); intent.putExtra(ACTION, (Parcelable) Action.ShowRegelmBuchungen); startActivity(intent); consumed = true; break; default: consumed = super.onOptionsItemSelected(item); break; } return consumed; }
From source file:com.torrenttunes.android.ui.ActionBarCastActivity.java
@Override public void onBackPressed() { // If the drawer is open, back will close it if (mDrawerLayout != null && mDrawerLayout.isDrawerOpen(Gravity.START)) { mDrawerLayout.closeDrawers();/*from w w w .j av a2 s . c o m*/ return; } // Otherwise, it may return to the previous fragment stack FragmentManager fragmentManager = getSupportFragmentManager(); if (fragmentManager.getBackStackEntryCount() > 0) { fragmentManager.popBackStack(); } else { // Lastly, it will rely on the system behavior for back super.onBackPressed(); } }
From source file:com.htc.dotdesign.ToolBoxService.java
@Override public void onCreate() { Log.d(DotDesignConstants.LOG_TAG, LOG_PREFIX + "onCreate"); super.onCreate(); Resources res = getResources(); mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE); mLocalBroadcastManager = LocalBroadcastManager.getInstance(this); if (mLocalBroadcastManager != null) { IntentFilter filter = new IntentFilter(); filter.addAction(SHOW_HIDE_TOOL_BAR); filter.addAction(USER_START_DRAWING); mLocalBroadcastManager.registerReceiver(mToolBarReceiver, filter); }/*from ww w . ja v a 2 s . co m*/ // Get full window size Display display = mWindowManager.getDefaultDisplay(); Point size = new Point(); display.getRealSize(size); mScreenWidth = size.x; mScreenHeight = size.y; // Get arrow width BitmapFactory.Options bitmapOptions = new BitmapFactory.Options(); bitmapOptions.inJustDecodeBounds = true; BitmapFactory.decodeResource(res, R.drawable.dot_design_popupmenu_arrow, bitmapOptions); mArrowWidth = bitmapOptions.outWidth; // Initialize LayoutParams mDragButtonParams = new WindowManager.LayoutParams(res.getDimensionPixelSize(R.dimen.drag_button_width), res.getDimensionPixelSize(R.dimen.drag_button_height), WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT); mDragButtonParams.gravity = Gravity.TOP | Gravity.START; mDragButtonParams.x = 0; mDragButtonParams.y = mScreenHeight / 2; mToolBarParams = new WindowManager.LayoutParams(res.getDimensionPixelSize(R.dimen.tool_bar_width), res.getDimensionPixelSize(R.dimen.tool_bar_height), WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT); mToolBarParams.alpha = 0.9f; mToolBarParams.gravity = Gravity.TOP | Gravity.START; mToolBarParams.x = 0; mToolBarParams.y = mDragButtonParams.y; // Initialize drag button width and height //mDragButtonWidth = res.getDimensionPixelSize(R.dimen.drag_button_width); mDragButtonHeight = res.getDimensionPixelSize(R.dimen.drag_button_height); mDragBtnColorIcon = (GradientDrawable) res.getDrawable(R.drawable.round_button); mDragBtnEraserIcon = res.getDrawable(R.drawable.dot_design_circle_shape_dark); // Inflate layout LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); mDragButton = inflater.inflate(R.layout.drag_button, null); mToolBarParent = inflater.inflate(R.layout.tool_bar, null); mPalette = inflater.inflate(R.layout.palette, null); mEraser = inflater.inflate(R.layout.eraser, null); mMenu = inflater.inflate(R.layout.menu, null); initToolBar(); initMenu(); initAnimation(); initBrushColor(); initDragButton(); mWindowManager.addView(mToolBarParent, mToolBarParams); mWindowManager.addView(mDragButton, mDragButtonParams); mToolBarParent.setVisibility(View.INVISIBLE); }
From source file:com.chinaftw.music.ui.ActionBarCastActivity.java
@Override public void onBackPressed() { // If the drawer is open, back will close it if (mDrawerLayout != null && mDrawerLayout.isDrawerOpen(Gravity.START)) { mDrawerLayout.closeDrawers();//www .j av a 2 s . c om return; } // Otherwise, it may return to the previous fragment stack FragmentManager fragmentManager = getFragmentManager(); if (fragmentManager.getBackStackEntryCount() > 0) { fragmentManager.popBackStack(); } else { // Lastly, it will rely on the system behavior for back super.onBackPressed(); } }
From source file:com.davisosa.structura.activities.base.BaseActivity.java
public void onDrawerItemClicked(final int itemId) { if (itemId == getSelfDrawerItem()) { mDrawerLayout.closeDrawer(Gravity.START); return;//from w ww.j a v a2s . co m } if (isSpecialItem(itemId)) { goToDrawerItem(itemId); } else { // Launch the target activity after a short delay, to allow the close animation to play. mHandler.postDelayed(new Runnable() { @Override public void run() { goToDrawerItem(itemId); } }, DRAWER_LAUNCH_DELAY); // Change the active item on the list so the user can see the item changed. setSelectedDrawerItem(itemId); } mDrawerLayout.closeDrawer(Gravity.START); }