List of usage examples for android.view Gravity BOTTOM
int BOTTOM
To view the source code for android.view Gravity BOTTOM.
Click Source Link
From source file:Main.java
/** * Creates an approximated cubic gradient using a multi-stop linear gradient. See * <a href="https://plus.google.com/+RomanNurik/posts/2QvHVFWrHZf">this post</a> for more * details.//from www .j a v a2 s. c om */ public static Drawable makeCubicGradientScrimDrawable(int baseColor, int numStops, int gravity) { // Generate a cache key by hashing together the inputs, based on the method described in the Effective Java book int cacheKeyHash = baseColor; cacheKeyHash = 31 * cacheKeyHash + numStops; cacheKeyHash = 31 * cacheKeyHash + gravity; Drawable cachedGradient = cubicGradientScrimCache.get(cacheKeyHash); if (cachedGradient != null) { return cachedGradient; } numStops = Math.max(numStops, 2); PaintDrawable paintDrawable = new PaintDrawable(); paintDrawable.setShape(new RectShape()); final int[] stopColors = new int[numStops]; int red = Color.red(baseColor); int green = Color.green(baseColor); int blue = Color.blue(baseColor); int alpha = Color.alpha(baseColor); for (int i = 0; i < numStops; i++) { float x = i * 1f / (numStops - 1); float opacity = constrain(0, 1, (float) Math.pow(x, 3)); stopColors[i] = Color.argb((int) (alpha * opacity), red, green, blue); } final float x0, x1, y0, y1; switch (gravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.LEFT: x0 = 1; x1 = 0; break; case Gravity.RIGHT: x0 = 0; x1 = 1; break; default: x0 = 0; x1 = 0; break; } switch (gravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.TOP: y0 = 1; y1 = 0; break; case Gravity.BOTTOM: y0 = 0; y1 = 1; break; default: y0 = 0; y1 = 0; break; } paintDrawable.setShaderFactory(new ShapeDrawable.ShaderFactory() { @Override public Shader resize(int width, int height) { return new LinearGradient(width * x0, height * y0, width * x1, height * y1, stopColors, null, Shader.TileMode.CLAMP); } }); cubicGradientScrimCache.put(cacheKeyHash, paintDrawable); return paintDrawable; }
From source file:com.bilibili.socialize.share.utils.selector.PopFullScreenSharePlatformSelector.java
@Override public void show() { createShareWindowIfNeed();//ww w . j a v a 2 s . c o m if (!mShareWindow.isShowing()) { mShareWindow.showAtLocation(mAnchorView, Gravity.BOTTOM, 0, 0); } showEnterAnimation(); }
From source file:com.example.android.unsplash.DetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_detail); postponeEnterTransition();// ww w. ja va 2s. c o m TransitionSet transitions = new TransitionSet(); Slide slide = new Slide(Gravity.BOTTOM); slide.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)); slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime)); transitions.addTransition(slide); transitions.addTransition(new Fade()); getWindow().setEnterTransition(transitions); Intent intent = getIntent(); sharedElementCallback = new DetailSharedElementEnterCallback(intent); setEnterSharedElementCallback(sharedElementCallback); try { initialItem = Integer.parseInt(intent.getData().getLastPathSegment()); } catch (NumberFormatException e) { initialItem = 0; } PhotoService.getInstance().getPhotosAsync(new PhotoService.PhotoCallback() { @Override public void success(ArrayList<Photo> photos) { setUpViewPager(photos); findViewById(android.R.id.empty).setVisibility(View.GONE); } @Override public void error() { finishAfterTransition(); } }); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setNavigationOnClickListener(navigationOnClickListener); super.onCreate(savedInstanceState); }
From source file:cn.apputest.ctria.section2.Dialog_DriverLicenseCard.java
public void alert_DriverLicenseCardDialog(Context context, EditText carnum) { // TODO Auto-generated method stub contextAlawys = context;//from w ww .j a va 2 s .co m preferencesuser = context.getSharedPreferences(Login.FILE_USER, Context.MODE_PRIVATE); String DBName = preferencesuser.getString(Login.KEY_NAME, "1"); helper = new DBHelper(context, DBName + "_DB"); mgr = new DBManager(helper); final Dialog dialog = new Dialog(context, R.style.add_dialog); View vv = LayoutInflater.from(context) .inflate(R.layout.section2activity_lucha2_alert_driverlicensecard_dialog, null); dialog.setCanceledOnTouchOutside(true); dialog.setContentView(vv); // dialog.getWindow().setLayout(480, 524); // dialog.getWindow().setLayout(720, 1050); Resources r = context.getResources(); int x = (int) r.getDimension(R.dimen.x320); int y = (int) r.getDimension(R.dimen.y350); dialog.getWindow().setLayout(x, y); dialog.getWindow().setGravity(Gravity.BOTTOM); Information = (TextView) vv.findViewById(R.id.DriverLicensecard); Information.setClickable(false); Information.setLongClickable(false); Information.setMovementMethod(ScrollingMovementMethod.getInstance()); getDriverLicense(carnum); ImageButton backButton = (ImageButton) vv.findViewById(R.id.backImageButton); backButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub dialog.dismiss(); } }); dialog.show(); }
From source file:com.example.android.support.transition.widget.ArcMotionUsage.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mRoot = findViewById(R.id.root);//from w w w.java 2 s . c o m mTarget = findViewById(R.id.target); mTransition = new ChangeBounds(); mTransition.setPathMotion(new ArcMotion()); mTransition.setInterpolator(new FastOutSlowInInterpolator()); mTransition.setDuration(500); findViewById(R.id.move).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TransitionManager.beginDelayedTransition(mRoot, mTransition); FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mTarget.getLayoutParams(); if ((lp.gravity & Gravity.START) == Gravity.START) { lp.gravity = Gravity.END | Gravity.BOTTOM; } else { lp.gravity = Gravity.START | Gravity.TOP; } mTarget.setLayoutParams(lp); } }); }
From source file:com.manning.androidhacks.hack016.MainActivity.java
public void bottomLeft(View v) { Toast toast = Toast.makeText(this, "Bottom Left!", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM | Gravity.LEFT, 0, 0); toast.show();// w w w.j av a2 s .c om }
From source file:com.example.song.myapplication.logger.LogFragment.java
public View inflateViews() { mScrollView = new ScrollView(getActivity()); ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mScrollView.setLayoutParams(scrollParams); mLogView = new com.example.song.myapplication.logger.LogView(getActivity()); ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams); logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; mLogView.setLayoutParams(logParams); mLogView.setClickable(true);//from w w w . ja v a 2 s . c om mLogView.setFocusable(true); mLogView.setTypeface(Typeface.MONOSPACE); // Want to set padding as 16 dips, setPadding takes pixels. Hooray math! int paddingDips = 16; double scale = getResources().getDisplayMetrics().density; int paddingPixels = (int) ((paddingDips * (scale)) + .5); mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels); mLogView.setCompoundDrawablePadding(paddingPixels); mLogView.setGravity(Gravity.BOTTOM); mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium); mScrollView.addView(mLogView); return mScrollView; }
From source file:com.aaagame.proframework.fragment.T_PaletteFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);//from www . j a va 2s . com fl.setBackgroundResource(drawables[position]); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); v.setGravity(Gravity.BOTTOM); v.setText("CARD " + (position + 1)); fl.addView(v); return fl; }
From source file:com.ryan.demostore.logger.LogFragment.java
public View inflateViews() { mScrollView = new ScrollView(getActivity()); ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mScrollView.setLayoutParams(scrollParams); mLogView = new LogView(getActivity()); ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams); logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; mLogView.setTextAppearance(android.R.style.TextAppearance_Material_Medium); mLogView.setLayoutParams(logParams); mLogView.setClickable(true);/* w w w . jav a 2 s . com*/ mLogView.setFocusable(true); mLogView.setTypeface(Typeface.create("monospace", Typeface.NORMAL)); // Want to set padding as 16 dips, setPadding takes pixels. Hooray math! int paddingDips = 16; double scale = getResources().getDisplayMetrics().density; int paddingPixels = (int) ((paddingDips * (scale)) + .5); mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels); mLogView.setCompoundDrawablePadding(paddingPixels); mLogView.setGravity(Gravity.BOTTOM); mScrollView.addView(mLogView); return mScrollView; }
From source file:com.eric.quora.fragment.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);// w w w. ja v a 2 s. co m fl.setBackgroundResource(mipmaps[position]); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); v.setGravity(Gravity.BOTTOM); v.setText("CARD " + (position + 1)); fl.addView(v); return fl; }