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.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//from ww w. j a v a2 s . co m 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. *//* w w w. j a v a 2 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 = 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
/** * 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 w ww . j a v a2 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; }
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 a v a 2 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.andryr.musicplayer.utils.ToolbarDrawerToggle.java
private void init(final Context context, DrawerLayout drawerLayout, Toolbar toolbar, int[] gravities) { mDrawerLayout = drawerLayout;// w w w .j a v a2s . 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.sinyuk.jianyi.utils.list.SlideInItemAnimator.java
@Override public boolean animateAdd(RecyclerView.ViewHolder holder) { holder.itemView.setAlpha(0f);//from w w w . j ava2 s .co m switch (slideFromEdge) { case Gravity.LEFT: holder.itemView.setTranslationX(-holder.itemView.getWidth() / 3); break; case Gravity.TOP: holder.itemView.setTranslationY(-holder.itemView.getHeight() / 3); break; case Gravity.RIGHT: holder.itemView.setTranslationX(holder.itemView.getWidth() / 3); break; default: // Gravity.BOTTOM holder.itemView.setTranslationY(holder.itemView.getHeight() / 3); } pendingAdds.add(holder); return true; }
From source file:com.manning.androidhacks.hack016.MainActivity.java
public void upperRight(View v) { Toast toast = Toast.makeText(this, "Upper Right!", Toast.LENGTH_SHORT); toast.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 0); toast.show();/*from w ww.j ava 2s . c o m*/ }
From source file:com.manning.androidhacks.hack016.MainActivity.java
public void bottomRight(View v) { Toast toast = Toast.makeText(this, "Bottom Right!", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM | Gravity.RIGHT, 0, 0); toast.show();//from w w w . ja va2 s. c o m }
From source file:com.iaraby.template.control.DetailsPagerAdapter.java
public Object instantiateItem(View container, int position) { View rootView = LayoutInflater.from(context).inflate(R.layout.details_item, null); int itemPosition = getItemPosition(position); //custom the text TextView text = (TextView) rootView.findViewById(R.id.details_text_item); FontManager.getInstance(context).setTextFont(text, FontManager.CONTENT); if (Preferences.getInstance(context).isRTL()) text.setGravity(Gravity.RIGHT); //set the text if (contentCur != null && contentCur.moveToPosition(itemPosition)) { String data = ""; data = contentCur.getString(contentCur.getColumnIndex(Content.COL_CONTENT)); text.setText(data);// w ww .j a v a 2 s . c om } //check if current position available in the cursor ((ViewPager) container).addView(rootView, 0); return rootView; }
From source file:com.hxqc.aroundservice.activity.DriversLicenseChangeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_drivers_license_change); mDrawerView = (DrawerLayout) findViewById(R.id.change_drawer); OtherUtil.setDrawerMode(mDrawerView); mNameView = (MaterialEditText) findViewById(R.id.change_name); mPhoneView = (MaterialEditText) findViewById(R.id.change_phone); mAddressView = (MaterialEditText) findViewById(R.id.change_address); mAddressView.setOnClickListener(this); mAddressDetailView = (MaterialEditText) findViewById(R.id.change_address_detail); findViewById(R.id.change_right).setLayoutParams(new DrawerLayout.LayoutParams( DisplayTools.getScreenWidth(this) / 5 * 4, DrawerLayout.LayoutParams.MATCH_PARENT, Gravity.RIGHT)); mAddressFragment = new CityChooseFragment(); mAddressFragment.setAreaChooseListener(this); getSupportFragmentManager().beginTransaction().replace(R.id.change_right, mAddressFragment).commit(); mOriginalFragment = (QueryProcessingPhotoFragmentV2) getSupportFragmentManager() .findFragmentById(R.id.change_drivers_license_original); mCopyFragment = (QueryProcessingPhotoFragmentV2) getSupportFragmentManager() .findFragmentById(R.id.change_drivers_license_copy); mFrontFragment = (QueryProcessingPhotoFragmentV2) getSupportFragmentManager() .findFragmentById(R.id.change_id_card_front); mBackFragment = (QueryProcessingPhotoFragmentV2) getSupportFragmentManager() .findFragmentById(R.id.change_id_card_back); mOriginalFragment.setTitle("??"); mOriginalFragment.setAactivityType(OrderDetailContants.DRIVER); mOriginalFragment.setClickAreaListener(true); mOriginalFragment.setSampleTitleViewVisibility(true); mOriginalFragment.setClickSampleTitleListener(this, R.drawable.ic_sample_license_origianl); mCopyFragment.setTitle("??"); mCopyFragment.setAactivityType(OrderDetailContants.DRIVER); mCopyFragment.setClickAreaListener(false); mCopyFragment.setSampleTitleViewVisibility(true); mCopyFragment.setClickSampleTitleListener(this, R.drawable.ic_sample_license_copy); mFrontFragment.setTitle("??"); mFrontFragment.setAactivityType(OrderDetailContants.ID); mFrontFragment.setClickAreaListener(true); mFrontFragment.setSampleTitleViewVisibility(true); mFrontFragment.changeImageView(true); mFrontFragment.setClickSampleTitleListener(this, R.drawable.ic_sample_identity_front); mBackFragment.setTitle("????"); mBackFragment.setAactivityType(OrderDetailContants.ID); mBackFragment.setClickAreaListener(false); mBackFragment.setSampleTitleViewVisibility(true); mBackFragment.changeImageView(true); mBackFragment.setClickSampleTitleListener(this, R.drawable.ic_sample_identity_back); findViewById(R.id.change_submit).setOnClickListener(this); //?/*from w w w . ja v a2s . com*/ UserInfoHelper.getInstance().getUserInfo(this, new UserInfoHelper.UserInfoAction() { @Override public void showUserInfo(User meData) { mNameView.setText(meData.fullname); mPhoneView.setText(meData.phoneNumber); } @Override public void onFinish() { } }, false); }