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./*w w w. j av a2 s . c o m*/ */ 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 = Math.max(0, Math.min(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.START: x0 = 1; x1 = 0; break; case Gravity.END: 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: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 ww w. j a v a 2 s . co m*/ */ 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 = MathUtil.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) { LinearGradient linearGradient = new LinearGradient(width * x0, height * y0, width * x1, height * y1, stopColors, null, Shader.TileMode.CLAMP); return linearGradient; } }); cubicGradientScrimCache.put(cacheKeyHash, paintDrawable); return paintDrawable; }
From source file:Main.java
/** * This helper method creates a 'nice' scrim or background protection for layering text over * an image. This non-linear scrim is less noticable than a linear or constant one. * * Borrowed from github.com/romannurik/muzei * * 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./* w ww . j a va 2s .c o m*/ */ public static Drawable makeCubicGradientScrimDrawable(int baseColor, int numStops, int gravity) { numStops = Math.max(numStops, 2); PaintDrawable paintDrawable = new PaintDrawable(); paintDrawable.setShape(new RectShape()); final int[] stopColors = new int[numStops]; int alpha = Color.alpha(baseColor); for (int i = 0; i < numStops; i++) { double x = i * 1f / (numStops - 1); double opacity = Math.max(0, Math.min(1, Math.pow(x, 3))); stopColors[i] = (baseColor & 0x00ffffff) | ((int) (alpha * opacity) << 24); } 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) { LinearGradient linearGradient = new LinearGradient(width * x0, height * y0, width * x1, height * y1, stopColors, null, Shader.TileMode.CLAMP); return linearGradient; } }); return paintDrawable; }
From source file:com.itsronald.materialviewpagerindicatorsample.SimpleJavaExampleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_simple_java_example); final ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); viewPager.setAdapter(new PagerAdapter(getSupportFragmentManager())); final ViewPager.LayoutParams layoutParams = new ViewPager.LayoutParams(); layoutParams.width = ViewPager.LayoutParams.MATCH_PARENT; layoutParams.height = ViewPager.LayoutParams.WRAP_CONTENT; layoutParams.gravity = Gravity.BOTTOM; final ViewPagerIndicator indicator = new ViewPagerIndicator(this); viewPager.addView(indicator, layoutParams); }
From source file:com.bilibili.socialize.share.utils.selector.PopWrapSharePlatformSelector.java
@Override public void show() { createShareWindowIfNeed(); if (!mShareWindow.isShowing()) { mShareWindow.showAtLocation(mAnchorView, Gravity.BOTTOM, 0, 0); } }
From source file:com.andryr.musicplayer.utils.ToolbarDrawerToggle.java
private void init(final Context context, DrawerLayout drawerLayout, Toolbar toolbar, int[] gravities) { mDrawerLayout = drawerLayout;/*from www .j ava2 s. c o m*/ mArrowDrawable = new DrawerArrowDrawable(context); mToolbar = toolbar; if (gravities == null) { mGravities = new int[] { Gravity.LEFT, Gravity.TOP, Gravity.RIGHT, Gravity.BOTTOM }; } else { mGravities = gravities; } mToolbar.setNavigationIcon(mArrowDrawable); mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toggleDrawers(); } }); }
From source file:com.github.xizzhu.simpletooltip.sample.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); findViewById(R.id.top_left_button).setOnClickListener(new View.OnClickListener() { @Override/* ww w . jav a 2s .com*/ public void onClick(View v) { showToolTipView(v, Gravity.RIGHT, "Simple tool tip!", ContextCompat.getColor(MainActivity.this, R.color.blue)); } }); findViewById(R.id.top_right_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showToolTipView(v, Gravity.BOTTOM, "It is yet another very simple tool tip!", ContextCompat.getColor(MainActivity.this, R.color.green)); } }); findViewById(R.id.central_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showToolTipView(v, Gravity.END, "It is a very simple tool tip in the center!", ContextCompat.getColor(MainActivity.this, R.color.magenta)); } }); findViewById(R.id.bottom_left_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showToolTipView(v, Gravity.TOP, "Tool tip, once more!", ContextCompat.getColor(MainActivity.this, R.color.maroon)); } }); findViewById(R.id.bottom_right_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showToolTipView(v, Gravity.LEFT, "Magical tool tip!", ContextCompat.getColor(MainActivity.this, R.color.navy)); } }); View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View v) { showToolTipViewWithParent((Button) v, Gravity.BOTTOM); } }; findViewById(R.id.button1).setOnClickListener(listener); findViewById(R.id.button2).setOnClickListener(listener); findViewById(R.id.button3).setOnClickListener(listener); findViewById(R.id.button4).setOnClickListener(listener); findViewById(R.id.button5).setOnClickListener(listener); findViewById(R.id.button6).setOnClickListener(listener); findViewById(R.id.button7).setOnClickListener(listener); showToolTipView(findViewById(R.id.central_button), Gravity.START, "A simple tool tip!", ContextCompat.getColor(MainActivity.this, R.color.magenta), 750L); }
From source file:Main.java
/** * Creates an approximated cubic gradient using a multi-stop linear gradient. *//*from w w w .ja v a2s . com*/ 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) { LinearGradient linearGradient = new LinearGradient(width * x0, height * y0, width * x1, height * y1, stopColors, null, Shader.TileMode.CLAMP); return linearGradient; } }); cubicGradientScrimCache.put(cacheKeyHash, paintDrawable); return paintDrawable; }
From source file:com.google.android.apps.santatracker.VillageNotificationActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_takeoff); mVillageView = (VillageView) findViewById(R.id.villageView); mVillage = (Village) getSupportFragmentManager().findFragmentByTag(VILLAGE_TAG); if (mVillage == null) { mVillage = new Village(); getSupportFragmentManager().beginTransaction().add(mVillage, VILLAGE_TAG).commit(); }// ww w .jav a2 s.c om mVillageView.setVillage(mVillage); //Align card to bottom if content is smaller than screen. CardScrollView cardScrollView = (CardScrollView) findViewById(R.id.card_scroll_view); cardScrollView.setCardGravity(Gravity.BOTTOM); mTextView = (TextView) findViewById(R.id.text); mTextView.setTypeface(Typeface.createFromAsset(getAssets(), getResources().getString(R.string.typeface_robotocondensed_light))); mTextView.setText(getIntent().getStringExtra(NotificationConstants.KEY_CONTENT)); }
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.//w w w . jav a 2 s . c o m */ public static Drawable makeCubicGradientScrimDrawable(int baseColor, int numStops, int gravity) { 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 = (float) Math.max(0, Math.min(1, 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) { LinearGradient linearGradient = new LinearGradient(width * x0, height * y0, width * x1, height * y1, stopColors, null, Shader.TileMode.CLAMP); return linearGradient; } }); return paintDrawable; }