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:com.facebook.react.views.drawer.ReactDrawerLayoutManager.java
@Override public @Nullable Map getExportedViewConstants() { return MapBuilder.of("DrawerPosition", MapBuilder.of("Left", Gravity.START, "Right", Gravity.END)); }
From source file:com.rodrigopontes.androidbubbles.BubblesManager.java
private void initialize() { windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Point point = new Point(); windowManager.getDefaultDisplay().getSize(point); screenWidth = (short) point.x; screenHeight = (short) point.y; int statusBarResId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); statusBarHeight = (short) context.getResources().getDimensionPixelSize(statusBarResId); bubbleTrash = new BubbleTrash(); bubbleTrashParams = new WindowManager.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, PixelFormat.TRANSLUCENT);/* ww w . ja v a 2 s . c o m*/ bubbleTrashParams.gravity = Gravity.TOP | Gravity.START; bubbleTrash.getFrameLayout().measure(screenWidth, screenHeight); bubbleTrashWidth = (short) (bubbleTrash.getFrameLayout().getMeasuredWidth() * BubblesProperties.TRASH_INCREASE_SIZE); bubbleTrashHeight = (short) (bubbleTrash.getFrameLayout().getMeasuredHeight() * BubblesProperties.TRASH_INCREASE_SIZE); bubbleTrash.getFrameLayout().setMinimumWidth(bubbleTrashWidth); bubbleTrash.getFrameLayout().setMinimumHeight(bubbleTrashHeight); bubbleTrash.getImageView().measure(screenWidth, screenHeight); bubbleTrash.getImageView().setX(bubbleTrashWidth / 2 - bubbleTrash.getImageView().getMeasuredWidth() / 2); bubbleTrash.getImageView().setY(bubbleTrashHeight / 2 - bubbleTrash.getImageView().getMeasuredHeight() / 2); bubbleTrash.getImageViewForeground().measure(screenWidth, screenHeight); bubbleTrash.getImageViewForeground() .setX(bubbleTrashWidth / 2 - bubbleTrash.getImageViewForeground().getMeasuredWidth() / 2); bubbleTrash.getImageViewForeground() .setY(bubbleTrashHeight / 2 - bubbleTrash.getImageViewForeground().getMeasuredHeight() / 2); bubbleTrashParams.x = (screenWidth - bubbleTrashWidth) / 2; bubbleTrashParams.y = screenHeight + BubblesProperties.TRASH_ENTER_SPEED; windowManager.addView(bubbleTrash.getFrameLayout(), bubbleTrashParams); }
From source file:org.docrj.smartcard.reader.NavDrawer.java
public boolean isOpen() { return mDrawerLayout.isDrawerOpen(Gravity.START | Gravity.LEFT); }
From source file:com.davisosa.structura.activities.base.BaseActivity.java
protected void closeDrawer() { if (mDrawerLayout != null) { mDrawerLayout.closeDrawer(Gravity.START); } }
From source file:org.catnut.ui.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mApp = CatnutApp.getTingtingApp();/* w ww . j a v a 2 s . c om*/ mActionBar = getActionBar(); mActionBar.setIcon(R.drawable.ic_title_home); setContentView(R.layout.main); // drawer specific mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); mDrawerLayout.setDrawerListener(this); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.open_drawer, R.string.close_drawer); // the whole left drawer mQuickReturnDrawer = (QuickReturnScrollView) findViewById(R.id.drawer); mQuickReturnDrawer.setCallbacks(this); mQuickReturnView = findViewById(R.id.quick_return); mPlaceholderView = findViewById(R.id.place_holder); mQuickReturnDrawer.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { onScrollChanged(mQuickReturnDrawer.getScrollY()); mMaxScrollY = mQuickReturnDrawer.computeVerticalScrollRange() - mQuickReturnDrawer.getHeight(); mQuickReturnHeight = mQuickReturnView.getHeight(); } }); // drawer customized view mProfileCover = (ImageView) findViewById(R.id.avatar_profile); mTextNick = (TextView) findViewById(R.id.nick); mDescription = (TextView) findViewById(R.id.description); prepareDrawer(); injectListeners(); if (savedInstanceState == null) { HomeTimelineFragment fragment = HomeTimelineFragment.getFragment(); mCallbacks = fragment; mRefreshCallback = fragment; getFragmentManager().beginTransaction() .replace(R.id.fragment_container, fragment, HomeTimelineFragment.TAG).commit(); } getFragmentManager().addOnBackStackChangedListener(this); if (mApp.getPreferences().getBoolean(getString(R.string.pref_enable_analytics), true)) { mTracker = EasyTracker.getInstance(this); } }
From source file:li.barter.activities.AbstractDrawerActivity.java
/** * Initializes the Navigation drawer. Call this in onCreate() of your Activity AFTER setting the * content view//from w w w . jav a 2s . c o m * * @param drawerLayoutResId The layout res id of the drawer * @param drawerContentResId The layout res id of the drawer content * @param isDrawerLockedOpen Whether the drawer is loaded directly on screen(for ex, in the case * of tablets) or whether it should be loaded off the screen */ protected void initDrawer(final int drawerLayoutResId, final int drawerContentResId, final boolean isDrawerLockedOpen) { mIsDrawerLoadedOnScreen = isDrawerLockedOpen; mDrawerLayout = (DrawerLayout) findViewById(drawerLayoutResId); if (mDrawerLayout == null) { throw new IllegalArgumentException( "Drawer Layout with id R.id.drawer_layout not found. Check your layout/resource id being sent"); } mNavFrameContent = (FrameLayout) findViewById(drawerContentResId); if (mNavFrameContent == null) { throw new IllegalArgumentException( "Drawer content with id R.id.frame_nav_drawer not found. Check the layout/resource id being sent"); } if (isDrawerActionBarToggleEnabled() && !isDrawerLockedOpen) { mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_navigation_drawer, R.string.drawer_open, R.string.drawer_closed) { @Override public void onDrawerOpened(final View drawerView) { super.onDrawerOpened(drawerView); // mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); invalidateOptionsMenu(); } @Override public void onDrawerClosed(final View drawerView) { super.onDrawerClosed(drawerView); // mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); invalidateOptionsMenu(); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mDrawerToggle.setDrawerIndicatorEnabled(true); } if (isDrawerLockedOpen) { mDrawerLayout.setScrimColor(Color.TRANSPARENT); mDrawerLayout.setDrawerShadow(null, Gravity.START); mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.START); } else { mDrawerLayout.setScrimColor(getResources().getColor(R.color.overlay_black_40p)); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.START); } /* In the case that the activity was destroyed in background, the system will take care of reinitializing the fragment for us*/ NavDrawerFragment fragment = (NavDrawerFragment) getSupportFragmentManager() .findFragmentByTag(AppConstants.FragmentTags.NAV_DRAWER); if (fragment == null) { fragment = (NavDrawerFragment) Fragment.instantiate(this, NavDrawerFragment.class.getName()); loadFragment(drawerContentResId, fragment, AppConstants.FragmentTags.NAV_DRAWER, false, null); } else { loadFragment(drawerContentResId, fragment, AppConstants.FragmentTags.NAV_DRAWER, false, null, false, true); } }
From source file:org.akop.crosswords.activity.MainActivity.java
@Override public void onBackPressed() { if (mDrawerLayout.isDrawerOpen(Gravity.START)) { mDrawerLayout.closeDrawers();/*from w ww.ja v a2s . c o m*/ return; } super.onBackPressed(); }
From source file:com.macleod2486.androidswissknife.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (drawer.isDrawerOpen(Gravity.START)) { drawer.closeDrawers();/*from w w w .j av a 2s.c o m*/ } else { drawer.openDrawer(Gravity.START); } return true; }
From source file:com.jaredrummler.materialspinner.MaterialSpinner.java
private void init(Context context, AttributeSet attrs) { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MaterialSpinner); int defaultColor = getTextColors().getDefaultColor(); backgroundColor = typedArray.getColor(R.styleable.MaterialSpinner_ms_background_color, Color.WHITE); textColor = typedArray.getColor(R.styleable.MaterialSpinner_ms_text_color, defaultColor); arrowColor = typedArray.getColor(R.styleable.MaterialSpinner_ms_arrow_tint, textColor); hideArrow = typedArray.getBoolean(R.styleable.MaterialSpinner_ms_hide_arrow, false); typedArray.recycle();// ww w .ja va 2 s. com setGravity(Gravity.CENTER_VERTICAL | Gravity.START); boolean rtl = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { Configuration config = getResources().getConfiguration(); rtl = config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; if (rtl) { setLayoutDirection(View.LAYOUT_DIRECTION_RTL); setTextDirection(View.TEXT_DIRECTION_RTL); } } Resources resources = getResources(); int left, right, bottom, top; left = right = bottom = top = resources.getDimensionPixelSize(R.dimen.ms__padding_top); if (rtl) { right = resources.getDimensionPixelSize(R.dimen.ms__padding_left); } else { left = resources.getDimensionPixelSize(R.dimen.ms__padding_left); } setClickable(true); setPadding(left, top, right, bottom); setBackgroundResource(R.drawable.ms__selector); if (!hideArrow) { arrowDrawable = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ms__arrow)); DrawableCompat.setTint(arrowDrawable, arrowColor); if (rtl) { setCompoundDrawablesWithIntrinsicBounds(arrowDrawable, null, null, null); } else { setCompoundDrawablesWithIntrinsicBounds(null, null, arrowDrawable, null); } } listView = new ListView(context); listView.setId(getId()); listView.setDivider(null); listView.setItemsCanFocus(true); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position >= selectedIndex && position < adapter.getCount()) { position++; } selectedIndex = position; nothingSelected = false; Object item = adapter.get(position); adapter.notifyItemSelected(position); setText(item.toString()); collapse(); if (onItemSelectedListener != null) { //noinspection unchecked onItemSelectedListener.onItemSelected(MaterialSpinner.this, position, id, item); } } }); popupWindow = new PopupWindow(context); popupWindow.setContentView(listView); popupWindow.setOutsideTouchable(true); popupWindow.setFocusable(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { popupWindow.setElevation(16); popupWindow.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.ms__drawable)); } else { popupWindow.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.ms__drop_down_shadow)); } if (backgroundColor != Color.WHITE) { // default color is white setBackgroundColor(backgroundColor); } if (textColor != defaultColor) { setTextColor(textColor); } popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { if (nothingSelected && onNothingSelectedListener != null) { onNothingSelectedListener.onNothingSelected(MaterialSpinner.this); } if (!hideArrow) { animateArrow(false); } } }); }
From source file:com.orange.ocara.ui.activity.BaseActivity.java
@Override public void onBackPressed() { if (drawerLayout.isDrawerOpen(Gravity.START)) { drawerLayout.closeDrawers();//from www . j a v a 2 s.c om return; } super.onBackPressed(); }