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.cleanwiz.applock.ui.activity.LockMainActivity.java
@Override public void onClickEvent(View view) { switch (view.getId()) { case R.id.btn_menu: drawerLayout.openDrawer(Gravity.LEFT); break;//from ww w.ja v a 2 s .co m case R.id.btn_more: btnClickMore(); break; case R.id.tab_box: vp_main.setCurrentItem(1, true); break; case R.id.tab_lock: vp_main.setCurrentItem(0, true); break; case R.id.lr_pop_log: startActivity(new Intent(this, LookMyPrivateActivity.class)); closePopView(); break; case R.id.lr_pop_set: startActivity(new Intent(this, SettingActivity.class)); closePopView(); break; case R.id.slide_share: share(); break; case R.id.slide_feedback: feedback(); break; case R.id.slide_check_update: checkVersion(); break; case R.id.slide_app: recommendApp(); break; case R.id.drawer_logo: break; default: break; } super.onClickEvent(view); }
From source file:com.abewy.android.apps.klyph.app.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /*// w ww . j ava2 s .c o m * if (KlyphSession.getSessionUserName() != null) * { * loggedIn = true; * setTitle(KlyphSession.getSessionUserName()); * } * else * { * if (KlyphFlags.IS_PRO_VERSION == true) * setTitle(R.string.app_pro_name); * else * setTitle(R.string.app_name); * } */ setTitle(""); if (Session.getActiveSession() == null || KlyphSession.getSessionUserId() == null || (Session.getActiveSession() != null && Session.getActiveSession().isOpened() == false)) { getActionBar().hide(); getFragmentManager().beginTransaction().add(R.id.main, new LoginFragment(), FRAGMENT_TAG).commit(); } // notificationsFragment.setHasOptionsMenu(false); adContainer = (ViewGroup) findViewById(R.id.ad); drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); drawerToggle = new ActionBarDrawerToggle(this, drawer, AttrUtil.getResourceId(this, R.attr.drawerIcon), R.string.open, R.string.close) { @Override public void onDrawerOpened(View view) { Log.d("MainActivity.onCreate(...).new ActionBarDrawerToggle() {...}", "onDrawerOpened: "); super.onDrawerOpened(view); Fragment fragment = getFragmentManager().findFragmentByTag(FRAGMENT_TAG); if (drawer.isDrawerOpen(Gravity.RIGHT)) { // drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, Gravity.RIGHT); if (notificationsFragment != null) { notificationsFragment.setHasOptionsMenu(true); notificationsFragment.onOpenPane(); } if (fragment != null) fragment.setHasOptionsMenu(false); } else if (drawer.isDrawerOpen(Gravity.LEFT)) { if (notificationsFragment != null) { notificationsFragment.setHasOptionsMenu(false); } if (fragment != null) fragment.setHasOptionsMenu(true); } invalidateOptionsMenu(); } @Override public void onDrawerClosed(View view) { super.onDrawerClosed(view); drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT); if (!drawer.isDrawerOpen(Gravity.RIGHT)) { if (notificationsFragment != null) notificationsFragment.setHasOptionsMenu(false); Fragment fragment = getFragmentManager().findFragmentByTag(FRAGMENT_TAG); if (fragment != null) fragment.setHasOptionsMenu(true); } invalidateOptionsMenu(); } }; drawer.setDrawerListener(drawerToggle); final List<String> labels = KlyphPreferences.getLeftDrawerMenuLabels(); classes = new ArrayList<String>(KlyphPreferences.getLeftDrawerMenuClasses()); classes.add("com.abewy.android.apps.klyph.fragment.UserTimeline"); navAdapter = new DrawerLayoutAdapter(getActionBar().getThemedContext(), R.layout.item_drawer_layout, labels); final ListView navList = (ListView) findViewById(R.id.drawer); // Setting drawers max width int maxWidth = getResources().getDimensionPixelSize(R.dimen.max_drawer_layout_width); int w = Math.min(KlyphDevice.getDeviceWidth(), KlyphDevice.getDeviceHeight()) - getResources().getDimensionPixelSize(R.dimen.dip_64); int finalWidth = Math.min(maxWidth, w); LayoutParams params = ((View) navList.getParent()).getLayoutParams(); params.width = finalWidth; ((View) navList.getParent()).setLayoutParams(params); final View notificationContainer = findViewById(R.id.notifications_container); params = notificationContainer.getLayoutParams(); params.width = finalWidth; notificationContainer.setLayoutParams(params); // End max width navList.setFadingEdgeLength(0); navList.setVerticalFadingEdgeEnabled(false); navList.setAdapter(navAdapter); navList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, final int pos, long id) { updateContent(pos); drawer.closeDrawer(Gravity.LEFT); } }); // Try to use more data here. ANDROID_ID is a single point of attack. // String deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID); // Library calls this when it's done. // mLicenseCheckerCallback = new MyLicenseCheckerCallback(); // Construct the LicenseChecker with a policy. // mChecker = new LicenseChecker(this, new ServerManagedPolicy(this, new AESObfuscator(SALT, getPackageName(), deviceId)), BASE64_PUBLIC_KEY); // mChecker.checkAccess(mLicenseCheckerCallback) // Facebook HashKey if (KlyphFlags.LOG_FACEBOOK_HASH) FacebookUtil.logHash(this); // Hierarchy View Connector if (KlyphFlags.ENABLE_HIERACHY_VIEW_CONNECTOR) HierachyViewUtil.connectHierarchyView(this); }
From source file:com.andremion.floatingnavigationview.FloatingNavigationView.java
private void attachNavigationView() { CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) getLayoutParams(); int gravity = Gravity.LEFT; if (layoutParams.getAnchorId() != View.NO_ID && layoutParams.anchorGravity != Gravity.NO_GRAVITY) { if (Gravity.isHorizontal(layoutParams.anchorGravity)) { gravity = layoutParams.anchorGravity; }//from w w w . ja va 2 s . c om } else if (layoutParams.gravity != Gravity.NO_GRAVITY) { if (Gravity.isHorizontal(layoutParams.gravity)) { gravity = layoutParams.gravity; } } // Gravity.START and Gravity.END don't work for views added in WindowManager with RTL. // We need to convert script specific gravity to absolute horizontal value // If horizontal direction is LTR, then START will set LEFT and END will set RIGHT. // If horizontal direction is RTL, then START will set RIGHT and END will set LEFT. gravity = Gravity.getAbsoluteGravity(gravity, getLayoutDirection()); mWindowManager.addView(mNavigationView, createLayoutParams(gravity)); }
From source file:com.facebook.react.flat.RCTText.java
public Layout.Alignment getAlignment() { boolean isRtl = getLayoutDirection() == YogaDirection.RTL; switch (mAlignment) { // Layout.Alignment.RIGHT and Layout.Alignment.LEFT are @hide :( case Gravity.LEFT: int index = isRtl ? ALIGNMENT_RIGHT : ALIGNMENT_LEFT; return Layout.Alignment.values()[index]; case Gravity.RIGHT: index = isRtl ? ALIGNMENT_LEFT : ALIGNMENT_RIGHT; return Layout.Alignment.values()[index]; case Gravity.CENTER: return Layout.Alignment.ALIGN_CENTER; case Gravity.NO_GRAVITY: default://from www . j a v a 2s . c om return Layout.Alignment.ALIGN_NORMAL; } }
From source file:com.gudong.appkit.ui.activity.MainActivity.java
@Override public void onBackPressed() { if (mDrawerLayout.isDrawerOpen(Gravity.LEFT)) { mDrawerLayout.closeDrawers();/* ww w . j a v a 2 s . c om*/ return; } if (System.currentTimeMillis() - lastTime < 2000) { super.onBackPressed(); } else { lastTime = System.currentTimeMillis(); Toast.makeText(MainActivity.this, getString(R.string.exit_point), Toast.LENGTH_SHORT).show(); } }
From source file:com.daiv.android.twitter.manipulations.widgets.NotificationDrawerLayout.java
public NotificationDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); 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, 0.5f, mLeftCallback); mLeftDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT); mLeftDragger.setMinVelocity(minVel); mLeftCallback.setDragger(mLeftDragger); mRightDragger = ViewDragHelper.create(this, 0.5f, mRightCallback); mRightDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_RIGHT); mRightDragger.setMinVelocity(minVel); mRightCallback.setDragger(mRightDragger); // So that we can catch the back button setFocusableInTouchMode(true);//from www . j a va 2s. c o m ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate()); ViewGroupCompat.setMotionEventSplittingEnabled(this, false); }
From source file:com.abewy.android.apps.openklyph.app.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /*//from w w w.j av a 2 s . c o m * if (KlyphSession.getSessionUserName() != null) * { * loggedIn = true; * setTitle(KlyphSession.getSessionUserName()); * } * else * { * if (KlyphFlags.IS_PRO_VERSION == true) * setTitle(R.string.app_pro_name); * else * setTitle(R.string.app_name); * } */ setTitle(""); if (Session.getActiveSession() == null || KlyphSession.getSessionUserId() == null || (Session.getActiveSession() != null && Session.getActiveSession().isOpened() == false)) { getActionBar().hide(); getFragmentManager().beginTransaction().add(R.id.main, new LoginFragment(), FRAGMENT_TAG).commit(); } // notificationsFragment.setHasOptionsMenu(false); adContainer = (ViewGroup) findViewById(R.id.ad); drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); drawerToggle = new ActionBarDrawerToggle(this, drawer, AttrUtil.getResourceId(this, R.attr.drawerIcon), R.string.open, R.string.close) { @Override public void onDrawerOpened(View view) { Log.d("MainActivity.onCreate(...).new ActionBarDrawerToggle() {...}", "onDrawerOpened: "); super.onDrawerOpened(view); Fragment fragment = getFragmentManager().findFragmentByTag(FRAGMENT_TAG); if (drawer.isDrawerOpen(Gravity.RIGHT)) { // drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, Gravity.RIGHT); if (notificationsFragment != null) { notificationsFragment.setHasOptionsMenu(true); notificationsFragment.onOpenPane(); } if (fragment != null) fragment.setHasOptionsMenu(false); } else if (drawer.isDrawerOpen(Gravity.LEFT)) { if (notificationsFragment != null) { notificationsFragment.setHasOptionsMenu(false); } if (fragment != null) fragment.setHasOptionsMenu(true); } invalidateOptionsMenu(); } @Override public void onDrawerClosed(View view) { super.onDrawerClosed(view); drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT); if (!drawer.isDrawerOpen(Gravity.RIGHT)) { if (notificationsFragment != null) notificationsFragment.setHasOptionsMenu(false); Fragment fragment = getFragmentManager().findFragmentByTag(FRAGMENT_TAG); if (fragment != null) fragment.setHasOptionsMenu(true); } invalidateOptionsMenu(); } }; drawer.setDrawerListener(drawerToggle); final List<String> labels = KlyphPreferences.getLeftDrawerMenuLabels(); classes = new ArrayList<String>(KlyphPreferences.getLeftDrawerMenuClasses()); classes.add("com.abewy.android.apps.openklyph.fragment.UserTimeline"); navAdapter = new DrawerLayoutAdapter(getActionBar().getThemedContext(), R.layout.item_drawer_layout, labels); final ListView navList = (ListView) findViewById(R.id.drawer); // Setting drawers max width int maxWidth = getResources().getDimensionPixelSize(R.dimen.max_drawer_layout_width); int w = Math.min(KlyphDevice.getDeviceWidth(), KlyphDevice.getDeviceHeight()) - getResources().getDimensionPixelSize(R.dimen.dip_64); int finalWidth = Math.min(maxWidth, w); LayoutParams params = ((View) navList.getParent()).getLayoutParams(); params.width = finalWidth; ((View) navList.getParent()).setLayoutParams(params); final View notificationContainer = findViewById(R.id.notifications_container); params = notificationContainer.getLayoutParams(); params.width = finalWidth; notificationContainer.setLayoutParams(params); // End max width navList.setFadingEdgeLength(0); navList.setVerticalFadingEdgeEnabled(false); navList.setAdapter(navAdapter); navList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, final int pos, long id) { updateContent(pos); drawer.closeDrawer(Gravity.LEFT); } }); // Try to use more data here. ANDROID_ID is a single point of attack. // String deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID); // Library calls this when it's done. // mLicenseCheckerCallback = new MyLicenseCheckerCallback(); // Construct the LicenseChecker with a policy. // mChecker = new LicenseChecker(this, new ServerManagedPolicy(this, new AESObfuscator(SALT, getPackageName(), deviceId)), BASE64_PUBLIC_KEY); // mChecker.checkAccess(mLicenseCheckerCallback) // Facebook HashKey if (KlyphFlags.LOG_FACEBOOK_HASH) FacebookUtil.logHash(this); // Hierarchy View Connector if (KlyphFlags.ENABLE_HIERACHY_VIEW_CONNECTOR) HierachyViewUtil.connectHierarchyView(this); }
From source file:com.crearo.gpslogger.GpsMainActivity.java
/** * Handles the hardware back-button press *//*ww w. j ava 2s. co m*/ public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && Session.isBoundToService()) { stopAndUnbindServiceIfRequired(); } if (keyCode == KeyEvent.KEYCODE_BACK) { DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawerLayout.isDrawerOpen(Gravity.LEFT)) { toggleDrawer(); return true; } } return super.onKeyDown(keyCode, event); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppObj.java
@Override public void render(final Context context, final ViewGroup frame, Obj obj, boolean allowInteractions) { PackageManager pm = context.getPackageManager(); Drawable icon = null;//from w w w.j av a 2s. c o m String appName; if (obj.getJson() != null && obj.getJson().has(ANDROID_PACKAGE_NAME)) { appName = obj.getJson().optString(ANDROID_PACKAGE_NAME); } else { appName = "Unknown"; } if (!(obj instanceof DbObj)) { if (appName.contains(".")) { appName = appName.substring(appName.lastIndexOf(".") + 1); } String text = "Preparing application " + appName + "..."; // TODO: Show Market icon or app icon. TextView valueTV = new TextView(context); valueTV.setText(text); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV); return; } DbObj dbParentObj = (DbObj) obj; boolean rendered = false; Intent launch = getLaunchIntent(context, dbParentObj); List<ResolveInfo> infos = pm.queryIntentActivities(launch, 0); if (infos.size() > 0) { ResolveInfo info = infos.get(0); if (info.activityInfo.labelRes != 0) { appName = info.activityInfo.loadLabel(pm).toString(); icon = info.loadIcon(pm); } else { appName = info.activityInfo.name; } } else { appName = obj.getJson().optString(ANDROID_PACKAGE_NAME); if (appName.contains(".")) { appName = appName.substring(appName.lastIndexOf(".") + 1); } } // TODO: Safer reference to containing view if (icon != null) { View parentView = (View) frame.getParent().getParent(); ImageView avatar = (ImageView) parentView.findViewById(R.id.icon); avatar.setImageDrawable(icon); TextView label = (TextView) parentView.findViewById(R.id.name_text); label.setText(appName); } // TODO: obj.getLatestChild().render(); String selection = getRenderableClause(); String[] selectionArgs = null; Cursor cursor = dbParentObj.getSubfeed().query(selection, selectionArgs); if (cursor.moveToFirst()) { DbObj dbObj = App.instance().getMusubi().objForCursor(cursor); DbObjects.getFeedRenderer(dbObj.getType()).render(context, frame, dbObj, allowInteractions); rendered = true; } if (!rendered) { String text; if (icon != null) { ImageView iv = new ImageView(context); iv.setImageDrawable(icon); iv.setAdjustViewBounds(true); iv.setMaxWidth(60); iv.setMaxHeight(60); iv.setLayoutParams(CommonLayouts.WRAPPED); frame.addView(iv); text = appName; } else { text = "New application: " + appName + "."; } // TODO: Show Market icon or app icon. TextView valueTV = new TextView(context); valueTV.setText(text); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV); } }
From source file:appteam.nith.hillffair.activities.HomeActivity.java
private void setupWindowAnimations() { // Re-enter transition is executed when returning to this activity if (Build.VERSION.SDK_INT >= 21) { Slide slideTransition = new Slide(); slideTransition.setSlideEdge(Gravity.LEFT); slideTransition.setDuration(800); getWindow().setReenterTransition(slideTransition); getWindow().setExitTransition(slideTransition); }//from w ww .ja v a 2 s .c o m }