List of usage examples for android.view Gravity LEFT
int LEFT
To view the source code for android.view Gravity LEFT.
Click Source Link
From source file:com.hippo.drawerlayout.DrawerLayout.java
@Override protected void onFinishInflate() { super.onFinishInflate(); final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); final int absGravity = GravityCompat.getAbsoluteGravity( ((LayoutParams) child.getLayoutParams()).gravity, ViewCompat.getLayoutDirection(child)); if (absGravity == Gravity.NO_GRAVITY) { if (mContentView != null) throw new IllegalStateException("There is more than one content view"); mContentView = child;/*from www . ja v a 2s . c o m*/ } else if ((absGravity & Gravity.LEFT) == Gravity.LEFT) { if (mLeftDrawer != null) throw new IllegalStateException("There is more than one left menu"); mLeftDrawer = child; } else if ((absGravity & Gravity.RIGHT) == Gravity.RIGHT) { if (mRightDrawer != null) throw new IllegalStateException("There is more than one right menu"); mRightDrawer = child; } else { throw new IllegalStateException("Child " + child + " at index " + i + " does not have a valid layout_gravity - must be Gravity.LEFT, " + "Gravity.RIGHT or Gravity.NO_GRAVITY"); } } if (mContentView == null) { throw new IllegalStateException("There is no content view"); } // Material is solid. // Input events cannot pass through material. if (mLeftDrawer != null) { mLeftDrawer.setClickable(true); } if (mRightDrawer != null) { mRightDrawer.setClickable(true); } mShadow = new ShadowView(getContext()); addView(mShadow, 1); }
From source file:com.example.haizhu.myvoiceassistant.ui.RobotChatActivity.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.image_voice_in_text: refreshBottomLayout(true);// w ww .jav a2s. com if (!hasShowTips) { result_show.setVisibility(View.VISIBLE); resultList.clear(); chatAdapter.notifyDataSetChanged(); hasShowTips = true; } break; case R.id.id_chat_send: if (!TextUtils.isEmpty(id_chat_msg.getText())) { TruingDataHandler.requestTruingAnswer(id_chat_msg.getText().toString()); addChatItem(id_chat_msg.getText().toString()); } id_chat_msg.setText(""); break; case R.id.image_keyboard: refreshBottomLayout(false); result_show.setVisibility(View.GONE); break; case R.id.image_help: Intent intent = new Intent(RobotChatActivity.this, HelpActivity.class); startActivity(intent); break; case R.id.top_more_item: drawer_layout.openDrawer(Gravity.LEFT); break; } }
From source file:ca.co.rufus.androidboilerplate.ui.DebugDrawerLayout.java
/** * Enable or disable interaction with all drawers. * * <p>This allows the application to restrict the user's ability to open or close * any drawer within this layout. DrawerLayout will still respond to calls to * {@link #openDrawer(int)}, {@link #closeDrawer(int)} and friends if a drawer is locked.</p> * * <p>Locking drawers open or closed will implicitly open or close * any drawers as appropriate.</p> * * @param lockMode The new lock mode for the given drawer. One of {@link #LOCK_MODE_UNLOCKED}, * {@link #LOCK_MODE_LOCKED_CLOSED} or {@link #LOCK_MODE_LOCKED_OPEN}. */// w w w . ja v a2 s.c o m public void setDrawerLockMode(@LockMode int lockMode) { setDrawerLockMode(lockMode, Gravity.LEFT); setDrawerLockMode(lockMode, Gravity.RIGHT); }
From source file:com.cyanogenmod.filemanager.ui.widgets.DrawerLayout.java
/** * Check the lock mode of the drawer with the given gravity. * * @param edgeGravity Gravity of the drawer to check * @return one of {@link #LOCK_MODE_UNLOCKED}, {@link #LOCK_MODE_LOCKED_CLOSED} or * {@link #LOCK_MODE_LOCKED_OPEN}. *//*from w ww .j a v a 2 s . c o m*/ public int getDrawerLockMode(int edgeGravity) { final int absGravity = Gravity.getAbsoluteGravity(edgeGravity, this.getLayoutDirection()); if (absGravity == Gravity.LEFT) { return mLockModeLeft; } else if (absGravity == Gravity.RIGHT) { return mLockModeRight; } return LOCK_MODE_UNLOCKED; }
From source file:com.aidy.bottomdrawerlayout.AllDrawerLayout.java
/** * Enable or disable interaction with the given drawer. * /*from ww w . j ava2 s .c om*/ * <p> * This allows the application to restrict the user's ability to open or * close the given drawer. DrawerLayout will still respond to calls to * {@link #openDrawer(int)}, {@link #closeDrawer(int)} and friends if a * drawer is locked. * </p> * * <p> * Locking a drawer open or closed will implicitly open or close that drawer * as appropriate. * </p> * * @param lockMode * The new lock mode for the given drawer. One of * {@link #LOCK_MODE_UNLOCKED}, {@link #LOCK_MODE_LOCKED_CLOSED} * or {@link #LOCK_MODE_LOCKED_OPEN}. * @param edgeGravity * Gravity.LEFT, RIGHT, START or END. Expresses which drawer to * change the mode for. * * @see #LOCK_MODE_UNLOCKED * @see #LOCK_MODE_LOCKED_CLOSED * @see #LOCK_MODE_LOCKED_OPEN */ public void setDrawerLockMode(int lockMode, int edgeGravity) { final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this)); final ViewDragHelper helper; switch (absGravity) { case Gravity.LEFT: mLockModeLeft = lockMode; helper = mLeftDragger; break; case Gravity.RIGHT: mLockModeRight = lockMode; helper = mRightDragger; break; case Gravity.TOP: mLockModeTop = lockMode; helper = mTopDragger; break; case Gravity.BOTTOM: mLockModeBottom = lockMode; helper = mBottomDragger; break; default: helper = mBottomDragger; break; } if (lockMode != LOCK_MODE_UNLOCKED) { // Cancel interaction in progress helper.cancel(); } switch (lockMode) { case LOCK_MODE_LOCKED_OPEN: final View toOpen = findDrawerWithGravity(absGravity); if (toOpen != null) { openDrawer(toOpen); } break; case LOCK_MODE_LOCKED_CLOSED: final View toClose = findDrawerWithGravity(absGravity); if (toClose != null) { closeDrawer(toClose); } break; // default: do nothing } }
From source file:com.abewy.android.apps.klyph.widget.KlyphDrawerLayout.java
/** * Check the lock mode of the drawer with the given gravity. * * @param edgeGravity Gravity of the drawer to check * @return one of {@link #LOCK_MODE_UNLOCKED}, {@link #LOCK_MODE_LOCKED_CLOSED} or * {@link #LOCK_MODE_LOCKED_OPEN}. *///from w w w . j a va 2s . c om public int getDrawerLockMode(int edgeGravity) { final int absGrav = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this)); if (absGrav == Gravity.LEFT) { return mLockModeLeft; } else if (absGrav == Gravity.RIGHT) { return mLockModeRight; } return LOCK_MODE_UNLOCKED; }
From source file:com.netease.qa.emmagee.service.EmmageeService.java
/** * create a floating window to show real-time data. *//*w w w . ja v a 2 s .c o m*/ private void createFloatingWindow() { SharedPreferences shared = getSharedPreferences("float_flag", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = shared.edit(); editor.putInt("float", 1); editor.commit(); windowManager = (WindowManager) getApplicationContext().getSystemService("window"); wmParams = ((MyApplication) getApplication()).getMywmParams(); wmParams.type = 2002; wmParams.flags |= 8; wmParams.gravity = Gravity.LEFT | Gravity.TOP; wmParams.x = 0; wmParams.y = 0; wmParams.width = WindowManager.LayoutParams.WRAP_CONTENT; wmParams.height = WindowManager.LayoutParams.WRAP_CONTENT; wmParams.format = 1; windowManager.addView(viFloatingWindow, wmParams); viFloatingWindow.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { x = event.getRawX(); y = event.getRawY() - statusBarHeight; switch (event.getAction()) { case MotionEvent.ACTION_DOWN: mTouchStartX = event.getX(); mTouchStartY = event.getY(); break; case MotionEvent.ACTION_MOVE: updateViewPosition(); break; case MotionEvent.ACTION_UP: updateViewPosition(); mTouchStartX = mTouchStartY = 0; break; } return true; } }); btnWifi.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { try { btnWifi = (Button) viFloatingWindow.findViewById(R.id.wifi); String buttonText = (String) btnWifi.getText(); String wifiText = getResources().getString(R.string.open_wifi); if (buttonText.equals(wifiText)) { wifiManager.setWifiEnabled(true); btnWifi.setText(R.string.close_wifi); } else { wifiManager.setWifiEnabled(false); btnWifi.setText(R.string.open_wifi); } } catch (Exception e) { Toast.makeText(viFloatingWindow.getContext(), getString(R.string.wifi_fail_toast), Toast.LENGTH_LONG).show(); Log.e(LOG_TAG, e.toString()); } } }); }
From source file:android.car.ui.provider.CarDrawerLayout.java
/** * Enable or disable interaction with the given drawer. * * <p>This allows the application to restrict the user's ability to open or close * the given drawer. DrawerLayout will still respond to calls to {@link #openDrawer()}, * {@link #closeDrawer()} and friends if a drawer is locked.</p> * * <p>Locking a drawer open or closed will implicitly open or close * that drawer as appropriate.</p> * * @param lockMode The new lock mode for the given drawer. One of {@link #LOCK_MODE_UNLOCKED}, * {@link #LOCK_MODE_LOCKED_CLOSED} or {@link #LOCK_MODE_LOCKED_OPEN}. * @param edgeGravity Gravity.LEFT, RIGHT, START or END. * Expresses which drawer to change the mode for. * * @see #LOCK_MODE_UNLOCKED/*from w w w.j a v a 2 s . co m*/ * @see #LOCK_MODE_LOCKED_CLOSED * @see #LOCK_MODE_LOCKED_OPEN */ public void setDrawerLockMode(int lockMode, int edgeGravity) { final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this)); if (absGravity == Gravity.LEFT) { mLockModeLeft = lockMode; } else if (absGravity == Gravity.RIGHT) { mLockModeRight = lockMode; } if (lockMode != LOCK_MODE_UNLOCKED) { // Cancel interaction in progress mDragger.cancel(); } switch (lockMode) { case LOCK_MODE_LOCKED_OPEN: openDrawer(); break; case LOCK_MODE_LOCKED_CLOSED: closeDrawer(); break; // default: do nothing } }
From source file:com.abewy.android.apps.klyph.app.MainActivity.java
private void endInit() { if (sessionInitalized == false) { if (KlyphFlags.LOG_ACCESS_TOKEN) Log.d("MainActivity", Session.getActiveSession().getAccessToken()); // setTitle(KlyphSession.getSessionUserName()); // If just logged in and notifications enabled, then start the // service if (loggedIn == false) { KlyphService.startSelectedServices(); }/*from w w w. j ava 2 s . c o m*/ final TextView tv = (TextView) findViewById(R.id.user_name); tv.setText(KlyphSession.getSessionUserName()); final View timelineView = findViewById(R.id.profile); timelineView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { updateContent(classes.size() - 1); drawer.closeDrawer(Gravity.LEFT); } }); if (KlyphPreferences.areBannerAdsEnabled()) { enableAds(true); } getActionBar().show(); loadData(); } }
From source file:com.hippo.ehviewer.ui.MainActivity.java
@Override public void onBackPressed() { if (mDrawerLayout != null && (mDrawerLayout.isDrawerOpen(Gravity.LEFT) || mDrawerLayout.isDrawerOpen(Gravity.RIGHT))) { mDrawerLayout.closeDrawers();/*from ww w . j a v a2 s.co m*/ } else { super.onBackPressed(); } }