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:edu.stanford.mobisocial.dungbeetle.feed.objects.LinkObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();/*from w ww. ja va 2 s . c o m*/ TextView valueTV = new TextView(context); String title; if (content.has(TITLE)) { title = "Link: " + content.optString(TITLE); } else { title = content.optString(URI); } valueTV.setText(title); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); if (Linkify.addLinks(valueTV, Linkify.ALL)) { if (!allowInteractions) valueTV.setMovementMethod(null); } frame.addView(valueTV); }
From source file:com.example.android.immersive.ImmersiveDrawerActivity.java
/** * Configure the navigation drawer/*from w ww . j a v a 2 s .co m*/ */ private void configureDrawer(Toolbar toolbar) { mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); NavigationView nv = (NavigationView) mDrawerLayout.findViewById(R.id.navdrawer_items_container); nv.setNavigationItemSelectedListener(this); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mDrawerLayout.openDrawer(Gravity.LEFT); } }); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, 0, 0) { @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); mDrawerLayout.addDrawerListener(mDrawerToggle); }
From source file:com.andrasta.dashi.MainActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { prefs = new SharedPreferencesHelper(this); setupOrientation();/*from www .j a v a2 s.c om*/ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ((DrawerLayout) findViewById(R.id.drawer)).openDrawer(Gravity.LEFT); laneView = (LaneView) findViewById(R.id.lane_view); polygonView = (PolygonView) findViewById(R.id.plate_frame); polygonView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { v.setVisibility(View.INVISIBLE); } }); recognitionResult = (TextView) findViewById(R.id.recognition_result); recognitionResult.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { printResultsBuffer.reset(); recognitionResult.setText(""); } }); textureView = (AutoFitTextureView) findViewById(R.id.texture); textureView.setSurfaceTextureListener(textureListener); textureView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { saveImageOnDisk.set(true); } }); spinner = (Spinner) findViewById(R.id.camera_resolutions); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Size size = (Size) parent.getAdapter().getItem(position); if (!cameraRecSize.equals(size)) { cameraRecSize = size; updatePolygonView(); camera.close(); alprHandler.stop(); openCamera(textureView.getWidth(), textureView.getHeight()); alprHandler.start(); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); display = getWindowManager().getDefaultDisplay(); licensePlateMatcher = LicensePlateMatcher.getInstance(prefs); File configDir = new File(prefs.getString(KEY_ALPR_CONFIG_DIR, null)); alprHandler = new ImageHandler(configDir, imageHandlerCallback, new Handler()); camera = new Camera(this, this); createCameraSizesAdapter(); try { locationHelper.start(this); } catch (IOException ioe) { Log.d(TAG, "Cannot start location", ioe); } }
From source file:android.support.v7.internal.widget.TintRatingBar.java
/** * Converts a drawable to a tiled version of itself. It will recursively * traverse layer and state list drawables. *///from w ww.java 2s . c o m private Drawable tileify(Drawable drawable, boolean clip) { if (drawable instanceof DrawableWrapper) { Drawable inner = ((DrawableWrapper) drawable).getWrappedDrawable(); if (inner != null) { inner = tileify(inner, clip); ((DrawableWrapper) drawable).setWrappedDrawable(inner); } } else if (drawable instanceof LayerDrawable) { LayerDrawable background = (LayerDrawable) drawable; final int N = background.getNumberOfLayers(); Drawable[] outDrawables = new Drawable[N]; for (int i = 0; i < N; i++) { int id = background.getId(i); outDrawables[i] = tileify(background.getDrawable(i), (id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg = new LayerDrawable(outDrawables); for (int i = 0; i < N; i++) { newBg.setId(i, background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap = ((BitmapDrawable) drawable).getBitmap(); if (mSampleTile == null) { mSampleTile = tileBitmap; } final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader = new BitmapShader(tileBitmap, Shader.TileMode.REPEAT, Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
From source file:com.ayoview.sample.textview.badge.ViewsFragment.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.counter: { counterBadge.incrementBadgeCount(1); break;//www. j a va 2s. c o m } case R.id.gravity: { gravityBadge.incrementBadgeCount(1); Log.d(getClass().getName(), String.valueOf(gravityBadge.getBadgeCount() % 9)); if (gravityBadge.getBadgeCount() % 9 == 0) { gravityBadge.setBadgeGravity(Gravity.LEFT | Gravity.TOP); } else if (gravityBadge.getBadgeCount() % 9 == 1) { gravityBadge.setBadgeGravity(Gravity.RIGHT | Gravity.BOTTOM); } else if (gravityBadge.getBadgeCount() % 9 == 2) { gravityBadge.setBadgeGravity(Gravity.LEFT | Gravity.BOTTOM); } else if (gravityBadge.getBadgeCount() % 9 == 3) { gravityBadge.setBadgeGravity(Gravity.RIGHT | Gravity.TOP); } else if (gravityBadge.getBadgeCount() % 9 == 4) { gravityBadge.setBadgeGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); } else if (gravityBadge.getBadgeCount() % 9 == 5) { gravityBadge.setBadgeGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); } else if (gravityBadge.getBadgeCount() % 9 == 6) { gravityBadge.setBadgeGravity(Gravity.CENTER); } else if (gravityBadge.getBadgeCount() % 9 == 7) { gravityBadge.setBadgeGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP); } else if (gravityBadge.getBadgeCount() % 9 == 8) { gravityBadge.setBadgeGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM); } break; } case R.id.visibility: { visibilityBadgeView .setVisibility(visibilityBadgeView.getVisibility() == View.GONE ? View.VISIBLE : View.GONE); break; } default: break; } }
From source file:com.chromium.fontinstaller.ui.main.MainActivity.java
@Override public void onBackPressed() { if (drawerLayout.isDrawerOpen(Gravity.START | Gravity.LEFT)) { drawerLayout.closeDrawers();//w ww . j a v a 2 s .com return; } super.onBackPressed(); }
From source file:foam.jellyfish.StarwispBuilder.java
public int BuildLayoutGravity(String p) { if (p.equals("centre")) return Gravity.CENTER; if (p.equals("left")) return Gravity.LEFT; if (p.equals("right")) return Gravity.RIGHT; if (p.equals("fill")) return Gravity.FILL; return Gravity.LEFT; }
From source file:com.ayuget.redface.ui.activity.BaseDrawerActivity.java
private void setupNavigationDrawer() { Log.d(LOG_TAG, "Setting up navigation drawer"); // Now retrieve the DrawerLayout so that we can set the status bar color. // This only takes effect on Lollipop, or when using translucentStatusBar // on KitKat. drawerLayout.setStatusBarBackgroundColor(UiUtils.getStatusBarBackgroundColor(this)); drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.LEFT); // Initiate drawer with "static" items initiateNavDrawer();//from ww w . ja v a2 s. c o m // Setup user details and load categories for active user updateActiveUser(); }
From source file:com.hippo.ehviewer.ui.scene.BaseScene.java
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // Update left drawer locked state if (needShowLeftDrawer()) { setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.LEFT); } else {/*from w w w. j av a 2 s. c o m*/ setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.LEFT); } // Update nav checked item setNavCheckedItem(getNavCheckedItem()); // Hide soft ime AppHelper.hideSoftInput(getActivity()); }
From source file:com.farmerbb.taskbar.activity.ContextMenuActivity.java
@SuppressLint("RtlHardcoded") @SuppressWarnings("deprecation") @Override//from w ww . ja va2s.com protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); LocalBroadcastManager.getInstance(this) .sendBroadcast(new Intent("com.farmerbb.taskbar.CONTEXT_MENU_APPEARING")); boolean isNonAppMenu = !getIntent().hasExtra("package_name") && !getIntent().hasExtra("app_name"); showStartMenu = getIntent().getBooleanExtra("launched_from_start_menu", false); isStartButton = isNonAppMenu && getIntent().getBooleanExtra("is_start_button", false); isOverflowMenu = isNonAppMenu && getIntent().getBooleanExtra("is_overflow_menu", false); contextMenuFix = getIntent().hasExtra("context_menu_fix"); // Determine where to position the dialog on screen WindowManager.LayoutParams params = getWindow().getAttributes(); DisplayManager dm = (DisplayManager) getSystemService(DISPLAY_SERVICE); Display display = dm.getDisplay(Display.DEFAULT_DISPLAY); int statusBarHeight = 0; int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) statusBarHeight = getResources().getDimensionPixelSize(resourceId); if (showStartMenu) { int x = getIntent().getIntExtra("x", 0); int y = getIntent().getIntExtra("y", 0); int offset = getResources().getDimensionPixelSize( isOverflowMenu ? R.dimen.context_menu_offset_overflow : R.dimen.context_menu_offset); switch (U.getTaskbarPosition(this)) { case "bottom_left": case "bottom_vertical_left": params.gravity = Gravity.BOTTOM | Gravity.LEFT; params.x = x; params.y = display.getHeight() - y - offset; break; case "bottom_right": case "bottom_vertical_right": params.gravity = Gravity.BOTTOM | Gravity.LEFT; params.x = x - getResources().getDimensionPixelSize(R.dimen.context_menu_width) + offset + offset; params.y = display.getHeight() - y - offset; break; case "top_left": case "top_vertical_left": params.gravity = Gravity.TOP | Gravity.LEFT; params.x = x; params.y = y - offset + statusBarHeight; break; case "top_right": case "top_vertical_right": params.gravity = Gravity.TOP | Gravity.LEFT; params.x = x - getResources().getDimensionPixelSize(R.dimen.context_menu_width) + offset + offset; params.y = y - offset + statusBarHeight; break; } } else { LocalBroadcastManager.getInstance(this) .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU")); int x = getIntent().getIntExtra("x", display.getWidth()); int y = getIntent().getIntExtra("y", display.getHeight()); int offset = getResources().getDimensionPixelSize(R.dimen.icon_size); switch (U.getTaskbarPosition(this)) { case "bottom_left": params.gravity = Gravity.BOTTOM | Gravity.LEFT; params.x = isStartButton ? 0 : x; params.y = offset; break; case "bottom_vertical_left": params.gravity = Gravity.BOTTOM | Gravity.LEFT; params.x = offset; params.y = display.getHeight() - y - (isStartButton ? 0 : offset); break; case "bottom_right": params.gravity = Gravity.BOTTOM | Gravity.RIGHT; params.x = display.getWidth() - x; params.y = offset; break; case "bottom_vertical_right": params.gravity = Gravity.BOTTOM | Gravity.RIGHT; params.x = offset; params.y = display.getHeight() - y - (isStartButton ? 0 : offset); break; case "top_left": params.gravity = Gravity.TOP | Gravity.LEFT; params.x = isStartButton ? 0 : x; params.y = offset; break; case "top_vertical_left": params.gravity = Gravity.TOP | Gravity.LEFT; params.x = offset; params.y = isStartButton ? 0 : y - statusBarHeight; break; case "top_right": params.gravity = Gravity.TOP | Gravity.RIGHT; params.x = display.getWidth() - x; params.y = offset; break; case "top_vertical_right": params.gravity = Gravity.TOP | Gravity.RIGHT; params.x = offset; params.y = isStartButton ? 0 : y - statusBarHeight; break; } } params.width = getResources().getDimensionPixelSize(R.dimen.context_menu_width); params.dimAmount = 0; getWindow().setAttributes(params); View view = findViewById(android.R.id.list); if (view != null) view.setPadding(0, 0, 0, 0); generateMenu(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("com.farmerbb.taskbar.START_MENU_APPEARING"); intentFilter.addAction("com.farmerbb.taskbar.DASHBOARD_APPEARING"); LocalBroadcastManager.getInstance(this).registerReceiver(finishReceiver, intentFilter); }