List of usage examples for android.view Gravity CENTER_VERTICAL
int CENTER_VERTICAL
To view the source code for android.view Gravity CENTER_VERTICAL.
Click Source Link
From source file:org.telegram.ui.Cells.ChatUnreadCell.java
public ChatUnreadCell(Context context) { super(context); FrameLayout frameLayout = new FrameLayout(context); frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.chat_drawable_tint)); //setBackgroundResource(R.drawable.newmsg_divider); frameLayout.setElevation(AndroidUtilities.dp(1)); addView(frameLayout,// w w w.ja v a2 s. c o m LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 27, Gravity.LEFT | Gravity.TOP, 0, 8, 0, 4)); ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.ic_ab_new); imageView.setPadding(0, AndroidUtilities.dp(2), 0, 0); frameLayout.addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL, 0, 0, 10, 0)); textView = new TextView(context); textView.setPadding(0, 0, 0, AndroidUtilities.dp(1)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); textView.setTextColor(Theme.CHAT_UNREAD_TEXT_COLOR); textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); frameLayout.addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); }
From source file:org.michaelbel.bottomsheet.BottomSheetCell.java
public BottomSheetCell(Context context) { super(context); iconView = new ImageView(context); iconView.setScaleType(ImageView.ScaleType.CENTER); FrameLayout.LayoutParams params1 = new FrameLayout.LayoutParams(Utils.dp(context, 24), Utils.dp(context, 24));// www .ja v a 2 s . c o m params1.gravity = Gravity.START | Gravity.CENTER_VERTICAL; params1.leftMargin = Utils.dp(context, 16); params1.rightMargin = Utils.dp(context, 16); iconView.setLayoutParams(params1); addView(iconView); textView = new TextView(context); textView.setLines(1); textView.setMaxLines(1); textView.setSingleLine(true); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); FrameLayout.LayoutParams params2 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params2.gravity = Gravity.START | Gravity.CENTER_VERTICAL; params2.leftMargin = Utils.dp(context, 16); params2.rightMargin = Utils.dp(context, 16); textView.setLayoutParams(params2); addView(textView); }
From source file:org.telegram.ui.Cells.CheckBoxCell.java
public CheckBoxCell(Context context) { super(context); if (paint == null) { paint = new Paint(); paint.setColor(ContextCompat.getColor(context, R.color.divider)); paint.setStrokeWidth(1);//from w ww . j av a2s . c o m } textView = new TextView(context); textView.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLines(1); textView.setMaxLines(1); textView.setSingleLine(true); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 17 : 46), 0, (LocaleController.isRTL ? 46 : 17), 0)); valueTextView = new TextView(context); valueTextView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent)); valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); valueTextView.setLines(1); valueTextView.setMaxLines(1); valueTextView.setSingleLine(true); valueTextView.setEllipsize(TextUtils.TruncateAt.END); valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL); addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, 17, 0, 17, 0)); checkBox = new CheckBox(context); checkBox.setClickable(false); checkBox.setFocusable(false); checkBox.setBackground(null); addView(checkBox, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, (LocaleController.isRTL ? 0 : 7), 0, (LocaleController.isRTL ? 7 : 0), 0)); }
From source file:org.telegram.ui.Cells.TextDetailSettingsCell.java
public TextDetailSettingsCell(Context context) { super(context); setElevation(AndroidUtilities.dp(2)); setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); if (paint == null) { paint = new Paint(); paint.setColor(ContextCompat.getColor(context, R.color.divider)); paint.setStrokeWidth(1);/*ww w . j av a2 s.c o m*/ } textView = new TextView(context); textView.setTextColor(ContextCompat.getColor(context, R.color.primary_text)/*0xff212121*/); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLines(1); textView.setMaxLines(1); textView.setSingleLine(true); textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 10, 17, 0)); valueTextView = new TextView(context); valueTextView.setTextColor(ContextCompat.getColor(context, R.color.secondary_text)/*0xff212121*/); valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); valueTextView.setLines(1); valueTextView.setMaxLines(1); valueTextView.setSingleLine(true); valueTextView.setPadding(0, 0, 0, 0); addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 35, 17, 0)); }
From source file:org.telegram.ui.Cells.RadioCell.java
public RadioCell(Context context) { super(context); if (paint == null) { paint = new Paint(); paint.setColor(ContextCompat.getColor(context, R.color.divider)); paint.setStrokeWidth(1);//from w w w . j av a2s .c o m } setElevation(AndroidUtilities.dp(2)); setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); textView = new TextView(context); textView.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLines(1); textView.setMaxLines(1); textView.setSingleLine(true); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 0, 17, 0)); radioButton = new RadioButton(context); radioButton.setClickable(false); radioButton.setFocusable(false); radioButton.setBackground(null); /*radioButton.setSize(AndroidUtilities.dp(20)); radioButton.setColor(0xffb3b3b3, 0xff37a9f0);*/ addView(radioButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, (LocaleController.isRTL ? 18 : 0), 0, (LocaleController.isRTL ? 0 : 18), 0)); }
From source file:org.telegram.ui.Cells.TextCheckCell.java
public TextCheckCell(Context context) { super(context); setElevation(AndroidUtilities.dp(2)); setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); if (paint == null) { paint = new Paint(); paint.setColor(ContextCompat.getColor(context, R.color.divider) /*0xffd9d9d9*/); paint.setStrokeWidth(1);/*from www . j ava2s . co m*/ } textView = new TextView(context); textView.setTextColor(ContextCompat.getColor(context, R.color.primary_text)/*0xff212121*/); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLines(1); textView.setMaxLines(1); textView.setSingleLine(true); textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); textView.setEllipsize(TextUtils.TruncateAt.END); addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 64 : 17, 0, LocaleController.isRTL ? 17 : 64, 0)); valueTextView = new TextView(context); valueTextView.setTextColor(ContextCompat.getColor(context, R.color.secondary_text)/*0xff212121*/); valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); valueTextView.setLines(1); valueTextView.setMaxLines(1); valueTextView.setSingleLine(true); valueTextView.setPadding(0, 0, 0, 0); valueTextView.setEllipsize(TextUtils.TruncateAt.END); addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 64 : 17, 35, LocaleController.isRTL ? 17 : 64, 0)); checkBox = new Switch(context); checkBox.setDuplicateParentStateEnabled(false); checkBox.setFocusable(false); checkBox.setFocusableInTouchMode(false); checkBox.setClickable(false); checkBox.setBackground(null); addView(checkBox, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 12, 0, 12, 0)); }
From source file:org.telegram.ui.Cells.TextColorCell.java
public TextColorCell(Context context) { super(context); setElevation(AndroidUtilities.dp(2)); setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); if (paint == null) { paint = new Paint(); paint.setColor(ContextCompat.getColor(context, R.color.divider)); paint.setStrokeWidth(1);//w ww . j a v a2 s . co m } colorDrawable = getResources().getDrawable(R.drawable.switch_to_on2); textView = new TextView(context); textView.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLines(1); textView.setMaxLines(1); textView.setSingleLine(true); textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 0, 17, 0)); }
From source file:com.common.android.lib.controls.view.indicator.IconPageIndicator.java
public IconPageIndicator(Context context, AttributeSet attrs) { super(context, attrs); setHorizontalScrollBarEnabled(false); mIconsLayout = new IcsLinearLayout(context, R.attr.vpiIconPageIndicatorStyle); mIconsLayout.setGravity(Gravity.CENTER_VERTICAL); addView(mIconsLayout, new LayoutParams(WRAP_CONTENT, WRAP_CONTENT, Gravity.CENTER)); }
From source file:org.telegram.ui.Cells.TextSettingsCell.java
public TextSettingsCell(Context context) { super(context); setElevation(AndroidUtilities.dp(2)); setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); if (paint == null) { paint = new Paint(); paint.setColor(ContextCompat.getColor(context, R.color.divider) /*0xffd9d9d9*/); paint.setStrokeWidth(1);//from w ww. ja v a 2s.co m } textView = new TextView(context); textView.setTextColor(ContextCompat.getColor(context, R.color.primary_text)/*0xff212121*/); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLines(1); textView.setMaxLines(1); textView.setSingleLine(true); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 0, 17, 0)); valueTextView = new TextView(context); valueTextView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent)); valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); valueTextView.setLines(1); valueTextView.setMaxLines(1); valueTextView.setSingleLine(true); valueTextView.setEllipsize(TextUtils.TruncateAt.END); valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL); addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, 17, 0, 17, 0)); valueImageView = new ImageView(context); valueImageView.setScaleType(ImageView.ScaleType.CENTER); valueImageView.setVisibility(INVISIBLE); addView(valueImageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 17, 0, 17, 0)); }
From source file:org.telegram.ui.Cells.MentionCell.java
public MentionCell(Context context) { super(context); setOrientation(HORIZONTAL);/*from ww w. j a v a 2 s . c o m*/ setBackgroundResource(R.drawable.list_selector); avatarDrawable = new AvatarDrawable(); avatarDrawable.setSmallStyle(true); imageView = new BackupImageView(context); imageView.setRoundRadius(AndroidUtilities.dp(14)); addView(imageView, LayoutHelper.createLinear(28, 28, 12, 4, 0, 0)); nameTextView = new TextView(context); nameTextView.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); nameTextView.setSingleLine(true); nameTextView.setGravity(Gravity.LEFT); nameTextView.setEllipsize(TextUtils.TruncateAt.END); addView(nameTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, 12, 0, 0, 0)); usernameTextView = new TextView(context); usernameTextView.setTextColor(0xff999999); usernameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); usernameTextView.setSingleLine(true); usernameTextView.setGravity(Gravity.LEFT); usernameTextView.setEllipsize(TextUtils.TruncateAt.END); addView(usernameTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, 12, 0, 8, 0)); }