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.bookkos.bircle.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); _context = getApplicationContext();/*ww w. j a v a2 s. co m*/ _activity = this; currentTime = new Time("Asia/Tokyo"); // exceptionHandler = new ExceptionHandler(_context); // Thread.setDefaultUncaughtExceptionHandler(exceptionHandler); // sharedPreference???, user_id?group_id?registration_id?? getUserData(); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // ?? WindowManager window_manager = getWindowManager(); Display display = window_manager.getDefaultDisplay(); Point point = new Point(); display.getSize(point); displayWidth = point.x; displayHeight = point.y; displayInch = getInch(); // ??4??????? textSize = 17 * (displayInch / 4); actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_USE_LOGO); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayUseLogoEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayHomeAsUpEnabled(false); String title_text = ""; subGroupText = ""; groupText = groupName; if (displayInch < 4.7) { title_text = "<small><small><small>??: </small></small></small>"; resizeTitleSizeTooSmall(); } else if (displayInch >= 4.7 && displayInch < 5.5) { title_text = "<small><small>??: </small></small>"; resizeTitleSizeSmall(); } else if (displayInch >= 5.5 && displayInch < 6.5) { title_text = "<small>??: </small>"; resizeTitleSizeMiddle(); } else if (displayInch >= 6.5 && displayInch < 8) { title_text = "<small>??: </small>"; resizeTitleSizeLarge(); } else { title_text = "??: "; } String modify_group_text = title_text + "<font color=#FF0000>" + groupName + "</font>"; actionBar.setTitle(Html.fromHtml(modify_group_text)); Resources resources = _context.getResources(); int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); titleBarHeight = resources.getDimensionPixelSize(resourceId); setContentView(R.layout.capture); returnBorrowHelpView = (ImageView) findViewById(R.id.return_borrow_help_view); returnBorrowHelpView.setImageResource(R.drawable.return_borrow_help); returnBorrowHelpView.setTranslationY(displayHeight / 5 + titleBarHeight); returnBorrowHelpView.setLayoutParams(new FrameLayout.LayoutParams(displayWidth, displayHeight / 5 + titleBarHeight, Gravity.BOTTOM | Gravity.CENTER)); registHelpView = (ImageView) findViewById(R.id.regist_help_view); registHelpView.setImageResource(R.drawable.regist_help); registHelpView.setTranslationY(displayHeight / 5 + titleBarHeight); registHelpView.setLayoutParams(new FrameLayout.LayoutParams(displayWidth, displayHeight / 5 + titleBarHeight, Gravity.BOTTOM | Gravity.CENTER)); registHelpView.setVisibility(View.GONE); leftDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); leftDrawer = (ListView) findViewById(R.id.left_drawer); textView = (TextView) findViewById(R.id.textView); modeText = (TextView) findViewById(R.id.mode_text); modeText.setTextColor(Color.rgb(56, 234, 123)); modeText.setTextSize(textSize); modeText.setTypeface(Typeface.SERIF.MONOSPACE, Typeface.BOLD); strokeColor = Color.rgb(56, 234, 123); borrowReturnButton = (Button) findViewById(R.id.borrowReturnButton); registButton = (Button) findViewById(R.id.registButton); returnHistoryButton = (Button) findViewById(R.id.return_history_button); helpViewButton = (Button) findViewById(R.id.help_view_button); registSelectShelfRelativeLayout = (RelativeLayout) findViewById(R.id.regist_select_shelf_relative_layout); textViewLinearLayout = (LinearLayout) findViewById(R.id.text_view_linear_layout); buttonLinearLayout = (LinearLayout) findViewById(R.id.button_linear_layout); listViewLinearLayout = (LinearLayout) findViewById(R.id.list_view_linear_layout); decisionButton = (Button) findViewById(R.id.decision_button); cancelButton = (Button) findViewById(R.id.cancel_button); shelfListView = (ListView) findViewById(R.id.shelf_list_view); tempTextView = (TextView) findViewById(R.id.temp_text_view); // bookListViewAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1); bookListViewAdapter = new BookListViewAdapter(_context, R.layout.book_list_row, this); bookRegistRelativeLayout = (RelativeLayout) findViewById(R.id.book_regist_relative_layout); bookRegistLinearLayout = (LinearLayout) findViewById(R.id.book_regist_linear_layout); bookRegistListViewLinearLayout = (LinearLayout) findViewById(R.id.book_regist_list_view_linear_layout); bookRegistListView = (ListView) findViewById(R.id.book_regist_list_view); bookRegistTextView = (TextView) findViewById(R.id.book_regist_text_view); bookRegistCancelButton = (Button) findViewById(R.id.book_regist_cancel_button); registFlag = 0; int borrowReturnButton_width = displayWidth / 5 * 2; int borrowReturnButton_height = displayHeight / 10; int borrowReturnButton_x = ((displayWidth / 2) - borrowReturnButton_width) / 2; int borrowReturnButton_y = displayHeight / 2 + titleBarHeight; borrowReturnButton.setTranslationX(borrowReturnButton_x); borrowReturnButton.setTranslationY(borrowReturnButton_y); borrowReturnButton .setLayoutParams(new FrameLayout.LayoutParams(borrowReturnButton_width, borrowReturnButton_height)); borrowReturnButton.setBackgroundColor(Color.rgb(56, 234, 123)); borrowReturnButton.setText("??\n"); borrowReturnButton.setTextSize(textSize * 7 / 10); borrowReturnButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { arrayList.clear(); registFlag = 0; borrowReturnButton.setText("??\n"); borrowReturnButton.setEnabled(false); borrowReturnButton.setTextColor(Color.WHITE); borrowReturnButton.setBackgroundColor(Color.rgb(56, 234, 123)); registButton.setText("?\n??"); registButton.setEnabled(true); registButton.setTextColor(Color.GRAY); registButton.setBackgroundColor(Color.argb(170, 21, 38, 45)); modeText.setText("??"); modeText.setTextColor(Color.rgb(56, 234, 123)); returnBorrowHelpView.setVisibility(View.VISIBLE); registHelpView.setVisibility(View.GONE); strokeColor = Color.rgb(56, 234, 123); } }); int registButton_width = displayWidth / 5 * 2; int registButton_height = displayHeight / 10; int registButton_x = (displayWidth / 2) + ((displayWidth / 2) - registButton_width) / 2; int registButton_y = displayHeight / 2 + titleBarHeight; registButton.setTranslationX(registButton_x); registButton.setTranslationY(registButton_y); registButton.setLayoutParams(new FrameLayout.LayoutParams(registButton_width, registButton_height)); registButton.setBackgroundColor(Color.argb(170, 21, 38, 45)); registButton.setTextColor(Color.GRAY); registButton.setTextSize(textSize * 7 / 10); registButton.setText("?\n??"); registButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { arrayList.clear(); registFlag = 1; borrowReturnButton.setText("??\n??"); borrowReturnButton.setEnabled(true); borrowReturnButton.setTextColor(Color.GRAY); borrowReturnButton.setBackgroundColor(Color.argb(170, 9, 54, 16)); registButton.setText("?\n"); registButton.setEnabled(false); registButton.setTextColor(Color.WHITE); registButton.setBackgroundColor(Color.rgb(62, 162, 229)); modeText.setText("?"); modeText.setTextColor(Color.rgb(62, 162, 229)); returnBorrowHelpView.setVisibility(View.GONE); registHelpView.setVisibility(View.VISIBLE); strokeColor = Color.rgb(62, 162, 229); } }); returnHistoryButton.setText("????"); returnHistoryButton.setTextSize(textSize * 7 / 10); returnHistoryButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { leftDrawerLayout.openDrawer(Gravity.RIGHT); // animateTranslationY(bookRegistRelativeLayout, displayHeight, displayHeight - displayHeight / 4 - titleBarHeight); } }); getReturnHistory(); getCurrentTime(); setHelpView(); setScanUnregisterBookView(); setBookRegistView(); arrayList = new ArrayList<String>(); tempRegistIsbn = ""; initBookRegistUrl = book_register_url + "?user_id=" + userId + "&group_id=" + groupId; initLendRegistUrl = lend_register_url + "?user_id=" + userId + "&group_id=" + groupId; initTemporaryLendRegistUrl = temporary_lend_register_url + "?user_id=" + userId + "&group_id=" + groupId; initCatalogRegistUrl = catalog_register_url + "?group_id=" + groupId + "&book_code="; initManuallyCatalogRegistUrl = manually_catalog_register_url + "?group_id=" + groupId + "&book_code="; getStatusUrl = get_status_url + "?group_id=" + groupId + "&user_id=" + userId; hasSurface = false; inactivityTimer = new InactivityTimer(this); bircleBeepManager = new BircleBeepManager(this); ambientLightManager = new AmbientLightManager(this); PreferenceManager.setDefaultValues(this, R.xml.preferences, false); toastText = ""; }
From source file:com.hippo.ehviewer.ui.scene.FavoritesScene.java
@Override @Implemented(FastScroller.OnDragHandlerListener.class) public void onEndDragHandler() { // Restore right drawer if (null != mRecyclerView && !mRecyclerView.isInCustomChoice()) { setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT); }/*w w w . j a v a2s . co m*/ if (mSearchBarMover != null) { mSearchBarMover.returnSearchBarPosition(); } }
From source file:ca.co.rufus.androidboilerplate.ui.DebugDrawerLayout.java
/** * Returns the title of the drawer with the given gravity. * * @param edgeGravity Gravity.LEFT, RIGHT, START or END. Expresses which * drawer to return the title for. * @return The title of the drawer, or null if none set. * @see #setDrawerTitle(int, CharSequence) *//*from ww w .j a va2 s. c o m*/ @Nullable public CharSequence getDrawerTitle(@EdgeGravity int edgeGravity) { final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this)); if (absGravity == Gravity.LEFT) { return mTitleLeft; } else if (absGravity == Gravity.RIGHT) { return mTitleRight; } return null; }
From source file:com.zyk.drawerlayout.widget.DrawerLayout.java
/** * Set a simple drawable used for the left or right shadow. The drawable provided must have a * nonzero intrinsic width. For API 21 and above, an elevation will be set on the drawer * instead of the drawable provided.//from w ww . j a v a 2 s.co m * * <p>Note that for better support for both left-to-right and right-to-left layout * directions, a drawable for RTL layout (in additional to the one in LTR layout) can be * defined with a resource qualifier "ldrtl" for API 17 and above with the gravity * {@link GravityCompat#START}. Alternatively, for API 23 and above, the drawable can * auto-mirrored such that the drawable will be mirrored in RTL layout.</p> * * @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, @EdgeGravity 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. */ if (SET_DRAWER_SHADOW_FROM_ELEVATION) { // No op. Drawer shadow will come from setting an elevation on the drawer. return; } if ((gravity & GravityCompat.START) == GravityCompat.START) { mShadowStart = shadowDrawable; } else if ((gravity & GravityCompat.END) == GravityCompat.END) { mShadowEnd = shadowDrawable; } else if ((gravity & Gravity.LEFT) == Gravity.LEFT) { mShadowLeft = shadowDrawable; } else if ((gravity & Gravity.TOP) == Gravity.TOP) { mShadowTop = shadowDrawable; } else if ((gravity & Gravity.RIGHT) == Gravity.RIGHT) { mShadowRight = shadowDrawable; } else if ((gravity & Gravity.BOTTOM) == Gravity.BOTTOM) { mShadowBottom = shadowDrawable; } else { return; } resolveShadowDrawables(); invalidate(); }
From source file:dev.dworks.apps.anexplorer.DocumentsActivity.java
public void setInfoDrawerOpen(boolean open) { if (mShowAsDialog) { //TODO: show detail fragment as dialog } else {// w w w . j a va 2 s . co m setRootsDrawerOpen(false); if (open) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT); mDrawerLayout.openDrawer(Gravity.RIGHT); } else { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT); mDrawerLayout.closeDrawer(Gravity.RIGHT); } } }
From source file:edu.cens.loci.ui.widget.GenericEditorView.java
private void updateWifiList(TableLayout table, LociWifiFingerprint wifi) { ArrayList<WifiViewListItem> items = new ArrayList<WifiViewListItem>(); HashMap<String, APInfoMapItem> apMap = wifi.getAps(); Set<String> keys = apMap.keySet(); Iterator<String> iter = keys.iterator(); while (iter.hasNext()) { String bssid = iter.next(); APInfoMapItem ap = apMap.get(bssid); items.add(new WifiViewListItem(bssid, ap.ssid, ap.rss, ap.count, ap.rssBuckets)); }/*from w ww . j ava2 s . co m*/ Collections.sort(items); table.setColumnCollapsed(0, false); table.setColumnCollapsed(1, true); table.setColumnShrinkable(0, true); for (int i = 0; i < mAddedRows.size(); i++) { table.removeView(mAddedRows.get(i)); } mAddedRows.clear(); int totalCount = wifi.getScanCount(); Context context = getContext(); for (WifiViewListItem item : items) { TableRow row = new TableRow(context); TextView ssidView = new TextView(context); ssidView.setText(item.ssid); //ssidView.setText("very very very veryvery very very very very very"); ssidView.setPadding(2, 2, 2, 2); ssidView.setTextColor(0xffffffff); TextView bssidView = new TextView(context); bssidView.setText(item.bssid); bssidView.setPadding(2, 2, 2, 2); bssidView.setTextColor(0xffffffff); TextView cntView = new TextView(context); cntView.setText("" + (item.count * 100) / totalCount); cntView.setPadding(2, 2, 2, 2); cntView.setGravity(Gravity.CENTER); cntView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); TextView rssView = new TextView(context); rssView.setText("" + item.rss); rssView.setPadding(2, 2, 6, 2); rssView.setGravity(Gravity.CENTER); rssView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); row.addView(ssidView, new TableRow.LayoutParams(0)); row.addView(bssidView, new TableRow.LayoutParams(1)); row.addView(cntView, new TableRow.LayoutParams(2)); row.addView(rssView, new TableRow.LayoutParams(3)); //Log.d(TAG, item.ssid); for (int i = 0; i < item.rssBuckets.length; i++) { TextView box = new TextView(context); box.setText(" "); box.setGravity(Gravity.RIGHT); box.setPadding(2, 2, 2, 2); box.setHeight(15); box.setGravity(Gravity.CENTER_VERTICAL); float colorVal = 256 * ((float) item.rssBuckets[i] / (float) wifi.getScanCount()); //Log.d(TAG, "colorVal=" + (int) colorVal + ", " + item.histogram[i]); int colorValInt = ((int) colorVal) - 1; if (colorValInt < 0) colorValInt = 0; box.setBackgroundColor(0xff000000 + colorValInt);//+ 0x000000ff * (item.histogram[i]/totScan)); box.setTextColor(0xffffffff); row.addView(box, new TableRow.LayoutParams(4 + i)); } row.setGravity(Gravity.CENTER); table.addView(row, new TableLayout.LayoutParams()); table.setColumnStretchable(3, true); mAddedRows.add(row); } }
From source file:com.facebook.litho.widget.TextSpec.java
private static Alignment getAlignment(int gravity) { final Alignment alignment; switch (gravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) { case Gravity.START: alignment = ALIGN_NORMAL;/*w w w . j a v a 2 s . co m*/ break; case Gravity.END: alignment = ALIGN_OPPOSITE; break; case Gravity.LEFT: // unsupported, default to normal alignment = ALIGN_NORMAL; break; case Gravity.RIGHT: // unsupported, default to opposite alignment = ALIGN_OPPOSITE; break; case Gravity.CENTER_HORIZONTAL: alignment = ALIGN_CENTER; break; default: alignment = textAlignment; break; } return alignment; }
From source file:com.hippo.ehviewer.ui.scene.DownloadsScene.java
@Override public View onCreateDrawerView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.drawer_list, container, false); final Context context = getContext2(); Assert.assertNotNull(context);/* w ww . ja v a 2s. co m*/ Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar); toolbar.setTitle(R.string.download_labels); toolbar.inflateMenu(R.menu.drawer_download); toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.action_settings: startScene(new Announcer(DownloadLabelsScene.class)); return true; case R.id.action_default_download_label: DownloadManager dm = mDownloadManager; if (null == dm) { return true; } List<DownloadLabel> list = dm.getLabelList(); final String[] items = new String[list.size() + 2]; items[0] = getString(R.string.let_me_select); items[1] = getString(R.string.default_download_label_name); for (int i = 0, n = list.size(); i < n; i++) { items[i + 2] = list.get(i).getLabel(); } new AlertDialog.Builder(context).setTitle(R.string.default_download_label) .setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { Settings.putHasDefaultDownloadLabel(false); } else { Settings.putHasDefaultDownloadLabel(true); String label; if (which == 1) { label = null; } else { label = items[which]; } Settings.putDefaultDownloadLabel(label); } } }).show(); return true; } return false; } }); List<DownloadLabel> list = EhApplication.getDownloadManager(context).getLabelList(); final List<String> labels = new ArrayList<>(list.size() + 1); // Add default label name labels.add(getString(R.string.default_download_label_name)); for (DownloadLabel raw : list) { labels.add(raw.getLabel()); } // TODO handle download label items update ListView listView = (ListView) view.findViewById(R.id.list_view); listView.setAdapter(new ArrayAdapter<>(context, R.layout.item_simple_list, labels)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String label; if (position == 0) { label = null; } else { label = labels.get(position); } if (!ObjectUtils.equal(label, mLabel)) { mLabel = label; updateForLabel(); updateView(); closeDrawer(Gravity.RIGHT); } } }); return view; }
From source file:com.gh4a.BaseActivity.java
private void setupNavigationDrawer() { mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_container); mLeftDrawer = (NavigationView) findViewById(R.id.left_drawer); applyHighlightColor(mLeftDrawer);//from w w w .j a v a 2s. c om mRightDrawer = (NavigationView) findViewById(R.id.right_drawer); applyHighlightColor(mRightDrawer); Toolbar toolBar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolBar); int drawerMenuResId = getLeftNavigationDrawerMenuResource(); if (drawerMenuResId != 0) { mLeftDrawer.inflateMenu(drawerMenuResId); mLeftDrawer.setNavigationItemSelectedListener(this); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolBar, 0, 0); mDrawerLayout.setDrawerListener(this); mLeftDrawerTitle = getLeftDrawerTitle(mLeftDrawer); if (mLeftDrawerTitle != null) { mLeftDrawer.addHeaderView(mLeftDrawerTitle); } } else { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.LEFT); } mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_left, Gravity.LEFT); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_right, Gravity.RIGHT); mDrawerLayout.setScrimColor(ContextCompat.getColor(this, R.color.drawer_scrim)); mRightDrawerTitle = mRightDrawer.inflateHeaderView(R.layout.drawer_title_right); updateRightNavigationDrawer(); }
From source file:com.amazon.appstream.fireclient.FireClientActivity.java
@Override public void onErrorMessage(final boolean fatal, final String message) { runOnUiThread(new Runnable() { @Override/* w w w . j ava2s . c o m*/ public void run() { if (mStopped) { Log.i(TAG, "Ignoring error during stopped state :" + (fatal ? "fatal" : "non fatal") + ":" + message); return; // ignore errors if we're stopped. } if (fatal) { // Tell the app it needs to pause. AppStreamInterface.pause(true); ErrorDialogFragment dialog = new ErrorDialogFragment(); dialog.setMessage(message); dialog.show(getSupportFragmentManager(), "ErrorDialogFragment"); // And finally stop AppStream; kill the interfaces to give us a clean slate. stopAppStream(); } else { if (mConnectDialog != null) { openConnectDialog(message); } else { Toast toast = Toast.makeText(FireClientActivity.this, message, Toast.LENGTH_LONG); toast.setGravity(Gravity.RIGHT | Gravity.BOTTOM, 10, 10); toast.show(); } } } }); }