Example usage for android.view Gravity CENTER_VERTICAL

List of usage examples for android.view Gravity CENTER_VERTICAL

Introduction

In this page you can find the example usage for android.view Gravity CENTER_VERTICAL.

Prototype

int CENTER_VERTICAL

To view the source code for android.view Gravity CENTER_VERTICAL.

Click Source Link

Document

Place object in the vertical center of its container, not changing its size.

Usage

From source file:Main.java

public static PopupWindow showPopWindow3(Context context, View targetView, View contentView, Integer width) {
    PopupWindow popupWindow = null;/*www. j  av  a  2s  .  c  om*/
    popupWindow = new PopupWindow(contentView, -2, -2);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    if (width != null) {
        popupWindow.setWidth(width);
    }
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAtLocation(targetView, Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL, 0, 0);
    return popupWindow;
}

From source file:org.telegram.ui.Cells.HashtagSearchCell.java

public HashtagSearchCell(Context context) {
    super(context);
    setGravity(Gravity.CENTER_VERTICAL);
    setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0);
    setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
    setTextColor(ContextCompat.getColor(context, R.color.primary_text));
    if (paint == null) {
        paint = new Paint();
        paint.setColor(ContextCompat.getColor(context, R.color.chat_list_divider));
    }// w ww  . j a v  a  2s  .  c o  m

    setBackgroundResource(R.drawable.list_selector);
}

From source file:org.telegram.ui.Cells.SharedMediaSectionCell.java

public SharedMediaSectionCell(Context context) {
    super(context);

    textView = new TextView(getContext());
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setTextColor(ContextCompat.getColor(context, R.color.secondary_text));
    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, 13, 0, 13, 0));
}

From source file:org.telegram.ui.Cells.GreySectionCell.java

public GreySectionCell(Context context) {
    super(context);

    setBackgroundColor(ContextCompat.getColor(context, R.color.search_type_background));

    textView = new TextView(getContext());
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setTextColor(ContextCompat.getColor(context, R.color.secondary_text));
    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, 16, 0, 16, 0));
}

From source file:org.telegram.ui.Cells.HeaderCell.java

public HeaderCell(Context context) {
    super(context);

    setElevation(AndroidUtilities.dp(2));
    setBackgroundColor(ContextCompat.getColor(context, R.color.card_background));

    textView = new TextView(getContext());
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent));
    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, 15, 17, 0));
}

From source file:org.telegram.ui.Cells.DrawerActionCell.java

public DrawerActionCell(Context context) {
    super(context);

    textView = new TextView(context);
    textView.setTextColor(ContextCompat.getColor(context, R.color.drawer_text));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setLines(1);//  w ww .ja va 2 s.c  o m
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
    textView.setCompoundDrawablePadding(AndroidUtilities.dp(34));
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT,
            Gravity.LEFT | Gravity.TOP, 14, 0, 16, 0));
}

From source file:org.telegram.ui.Cells.TextBlockCell.java

public TextBlockCell(Context context) {
    super(context);

    if (paint == null) {
        paint = new Paint();
        paint.setColor(ContextCompat.getColor(context, R.color.divider));
        paint.setStrokeWidth(1);/*www . ja  v a 2s.com*/
    }

    textView = new TextView(context);
    textView.setTextColor(ContextCompat.getColor(context, R.color.primary_text));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT,
            (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 10, 17, 10));
}

From source file:ir.besteveryeverapp.ui.Cells.DrawerActionCell.java

public DrawerActionCell(Context context) {
    super(context);

    color = SkinMan.currentSkin.drawerNamesColor();

    //:ramin//from w w w.j  a  v a  2 s .co  m
    textView = new TextView(context);
    textView.setTypeface(FontManager.instance().getTypeface());
    textView.setTextColor(
            //0xff444444
            color);

    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    textView.setTypeface(FontManager.instance().getTypeface());
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
    textView.setCompoundDrawablePadding(AndroidUtilities.dp(34));
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT,
            Gravity.LEFT | Gravity.TOP, 14, 0, 16, 0));
}

From source file:org.borderstone.tagtags.convenience.widgets.BButton.java

public BButton(Context context) {
    super(context);

    super.setTextSize(Constants.fontSize);
    this.setTextColor(Color.BLACK);

    this.setBackgroundResource(R.drawable.custom_button);
    if (android.os.Build.VERSION.SDK_INT >= 21)
        this.setStateListAnimator(null);

    this.setTextColor(Color.WHITE);
    this.setAllCaps(false);
    this.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);

    this.setClickable(true);
}

From source file:com.fjoglar.etsitnoticias.utils.UiUtils.java

/**
 * Configure the TextViews that will show the attachments of the new.
 *
 * @param textView      TextView to be configured.
 * @param title         Text shown in TextView
 * @param downloadLink  Link attached to TextView.
 * @param fileType      Type of file of the attachment.
 * @param context       The context of activity.
 *///from w ww  .  j a v  a 2s  .  com
public static void configureTextView(TextView textView, String title, final String downloadLink,
        Attachment.FILE_TYPE fileType, final Context context) {

    final int TEXT_VIEW_MIN_HEIGHT = 40;
    final int TEXT_VIEW_MARGIN_TOP = 4;

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    params.setMargins(0, convertDpToPx(TEXT_VIEW_MARGIN_TOP, context), 0, 0);
    textView.setLayoutParams(params);

    textView.setText(title);
    textView.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));
    textView.setMinHeight(convertDpToPx(TEXT_VIEW_MIN_HEIGHT, context));
    textView.setGravity(Gravity.CENTER_VERTICAL);

    switch (fileType) {
    case FILE:
        textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_file, 0, 0, 0);
        break;
    case IMAGE:
        textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_photo, 0, 0, 0);
        break;
    case FOLDER:
        textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_folder, 0, 0, 0);
        break;
    default:
        textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_link, 0, 0, 0);
        break;
    }

    textView.setCompoundDrawablePadding(convertDpToPx(4, context));

    TypedValue typedValue = new TypedValue();
    context.getTheme().resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true);
    textView.setBackgroundResource(typedValue.resourceId);

    textView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Navigator.getInstance().openUrl(context, downloadLink);
        }
    });
}