Java Code Examples for android.widget.TextView#setSingleLine()

The following examples show how to use android.widget.TextView#setSingleLine() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RadioColorCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public RadioColorCell(Context context) {
    super(context);

    radioButton = new RadioButton(context);
    radioButton.setSize(AndroidUtilities.dp(20));
    radioButton.setColor(Theme.getColor(Theme.key_dialogRadioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
    addView(radioButton, LayoutHelper.createFrame(22, 22, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 18), 13, (LocaleController.isRTL ? 18 : 0), 0));

    textView = new TextView(context);
    textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    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, (LocaleController.isRTL ? 17 : 51), 12, (LocaleController.isRTL ? 51 : 17), 0));
}
 
Example 2
Source File: HarEntryViewBar.java    From CapturePacket with MIT License 6 votes vote down vote up
private void createTextView(ItemEntry entry, float density) {
    Context context = getContext();
    TextView textView = new TextView(context);
    if (mIsTitle) {
        textView.getPaint().setFakeBoldText(true);
        textView.setTextColor(Color.BLACK);
        textView.setText(entry.text);
    }
    textView.setGravity(Gravity.CENTER_VERTICAL);
    textView.setTextSize(12);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setSingleLine();
    LayoutParams params = new LayoutParams((int) (density * entry.width + 0.5), ViewGroup.LayoutParams.MATCH_PARENT);
    params.leftMargin = params.rightMargin = (int) (density * 5 + 0.5);
    addView(textView, params);
}
 
Example 3
Source File: AlertDialog.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public AlertDialogCell(Context context) {
    super(context);

    setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_dialogButtonSelector), 2));
    setPadding(AndroidUtilities.dp(23), 0, AndroidUtilities.dp(23), 0);

    imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogIcon), PorterDuff.Mode.MULTIPLY));
    addView(imageView, LayoutHelper.createFrame(24, 24, Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)));

    textView = new TextView(context);
    textView.setLines(1);
    textView.setSingleLine(true);
    textView.setGravity(Gravity.CENTER_HORIZONTAL);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL));
}
 
Example 4
Source File: TextPriceCell.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public TextPriceCell(Context context) {
    super(context);

    setWillNotDraw(false);

    textView = new TextView(context);
    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.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 21, 0, 21, 0));

    valueTextView = new TextView(context);
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    valueTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    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, 21, 0, 21, 0));
}
 
Example 5
Source File: CheckBoxUserCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public CheckBoxUserCell(Context context, boolean alert) {
    super(context);

    textView = new TextView(context);
    textView.setTextColor(Theme.getColor(alert ? Theme.key_dialogTextBlack : Theme.key_windowBackgroundWhiteBlackText));
    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 : 94), 0, (LocaleController.isRTL ? 94 : 17), 0));

    avatarDrawable = new AvatarDrawable();
    imageView = new BackupImageView(context);
    imageView.setRoundRadius(AndroidUtilities.dp(36));
    addView(imageView, LayoutHelper.createFrame(36, 36, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 48, 6, 48, 0));

    checkBox = new CheckBoxSquare(context, alert);
    addView(checkBox, LayoutHelper.createFrame(18, 18, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 17), 15, (LocaleController.isRTL ? 17 : 0), 0));
}
 
Example 6
Source File: ChatAttachAlert.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public AttachBotButton(Context context) {
    super(context);

    imageView = new BackupImageView(context);
    imageView.setRoundRadius(AndroidUtilities.dp(25));
    addView(imageView, LayoutHelper.createFrame(46, 46, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 9, 0, 0));

    if (Build.VERSION.SDK_INT >= 21) {
        View selector = new View(context);
        selector.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_dialogButtonSelector), 1, AndroidUtilities.dp(23)));
        addView(selector, LayoutHelper.createFrame(46, 46, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 9, 0, 0));
    }

    nameTextView = new TextView(context);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    nameTextView.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
    nameTextView.setLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 6, 60, 6, 0));
}
 
Example 7
Source File: AlertDialog.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public AlertDialogCell(Context context) {
    super(context);

    setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_dialogButtonSelector), 2));
    setPadding(AndroidUtilities.dp(23), 0, AndroidUtilities.dp(23), 0);

    imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogIcon), PorterDuff.Mode.MULTIPLY));
    addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 40, Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)));

    textView = new TextView(context);
    textView.setLines(1);
    textView.setSingleLine(true);
    textView.setGravity(Gravity.CENTER_HORIZONTAL);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL));
}
 
Example 8
Source File: FriendListItem.java    From enjoyshop with Apache License 2.0 5 votes vote down vote up
public FriendListItem(Context context, float ratio) {
	super(context);
	int itemPadding = (int) (ratio * DESIGN_ITEM_PADDING);
	setPadding(itemPadding, 0, itemPadding, 0);
	setMinimumHeight((int) (ratio * DESIGN_ITEM_HEIGHT));
	setBackgroundColor(0xffffffff);

	ivCheck = new ImageView(context);
	LayoutParams lp = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lp.gravity = Gravity.CENTER_VERTICAL;
	addView(ivCheck, lp);

	aivIcon = new AsyncImageView(context);
	int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH);
	lp = new LayoutParams(avatarWidth, avatarWidth);
	lp.gravity = Gravity.CENTER_VERTICAL;
	int avatarMargin = (int) (ratio * DESIGN_AVATAR_PADDING);
	lp.setMargins(avatarMargin, 0, avatarMargin, 0);
	addView(aivIcon, lp);

	tvName = new TextView(context);
	tvName.setTextColor(0xff000000);
	tvName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvName.setSingleLine();
	lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lp.gravity = Gravity.CENTER_VERTICAL;
	lp.weight = 1;
	addView(tvName, lp);

	int resId = ResHelper.getBitmapRes(context, "ssdk_oks_classic_check_checked");
	if (resId > 0) {
		bmChd = BitmapFactory.decodeResource(context.getResources(), resId);
	}
	resId = ResHelper.getBitmapRes(getContext(), "ssdk_oks_classic_check_default");
	if (resId > 0) {
		bmUnch = BitmapFactory.decodeResource(context.getResources(), resId);
	}
}
 
Example 9
Source File: FeaturedStickerSetCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public FeaturedStickerSetCell(Context context) {
    super(context);

    textView = new TextView(context);
    textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    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);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, LocaleController.isRTL ? 22 : 71, 10, LocaleController.isRTL ? 71 : 22, 0));

    valueTextView = new TextView(context);
    valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    valueTextView.setLines(1);
    valueTextView.setMaxLines(1);
    valueTextView.setSingleLine(true);
    valueTextView.setEllipsize(TextUtils.TruncateAt.END);
    valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, LocaleController.isRTL ? 100 : 71, 35, LocaleController.isRTL ? 71 : 100, 0));

    imageView = new BackupImageView(context);
    imageView.setAspectFit(true);
    imageView.setLayerNum(1);
    addView(imageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 12, 8, LocaleController.isRTL ? 12 : 0, 0));

    addButton = new ProgressButton(context);
    addButton.setText(LocaleController.getString("Add", R.string.Add));
    addButton.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText));
    addButton.setProgressColor(Theme.getColor(Theme.key_featuredStickers_buttonProgress));
    addButton.setBackgroundRoundRect(Theme.getColor(Theme.key_featuredStickers_addButton), Theme.getColor(Theme.key_featuredStickers_addButtonPressed));
    addView(addButton, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, 28, Gravity.TOP | Gravity.END, 0, 18, 14, 0));

    checkImage = new ImageView(context);
    checkImage.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_featuredStickers_addedIcon), PorterDuff.Mode.MULTIPLY));
    checkImage.setImageResource(R.drawable.sticker_added);
    addView(checkImage, LayoutHelper.createFrame(19, 14));
}
 
Example 10
Source File: RadioButtonCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public RadioButtonCell(Context context, boolean dialog) {
    super(context);

    radioButton = new RadioButton(context);
    radioButton.setSize(AndroidUtilities.dp(20));
    if (dialog) {
        radioButton.setColor(Theme.getColor(Theme.key_dialogRadioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
    } else {
        radioButton.setColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_radioBackgroundChecked));
    }
    addView(radioButton, LayoutHelper.createFrame(22, 22, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 20), 10, (LocaleController.isRTL ? 20 : 0), 0));

    textView = new TextView(context);
    if (dialog) {
        textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    } else {
        textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    }
    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, (LocaleController.isRTL ? 23 : 61), 10, (LocaleController.isRTL ? 61 : 23), 0));

    valueTextView = new TextView(context);
    if (dialog) {
        valueTextView.setTextColor(Theme.getColor(Theme.key_dialogTextGray2));
    } else {
        valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
    }
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    valueTextView.setLines(0);
    valueTextView.setMaxLines(0);
    valueTextView.setSingleLine(false);
    valueTextView.setPadding(0, 0, 0, AndroidUtilities.dp(12));
    addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 17 : 61), 35, (LocaleController.isRTL ? 61 : 17), 0));
}
 
Example 11
Source File: MentionCell.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public MentionCell(Context context) {
    super(context);

    setOrientation(HORIZONTAL);

    avatarDrawable = new AvatarDrawable();
    avatarDrawable.setTextSize(AndroidUtilities.dp(12));

    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(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    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(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3));
    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));
}
 
Example 12
Source File: PagerSlidingTabStrip.java    From Android-ParallaxHeaderViewPager with Apache License 2.0 5 votes vote down vote up
private void addTextTab(final int position, String title) {

		TextView tab = new TextView(getContext());
		tab.setText(title);
		tab.setGravity(Gravity.CENTER);
		tab.setSingleLine();

		addTab(position, tab);
	}
 
Example 13
Source File: PagerSlidingTabStrip.java    From droidddle with Apache License 2.0 5 votes vote down vote up
private void addTextTab(final int position, String title) {

        TextView tab = new TextView(getContext());
        tab.setText(title);
        tab.setGravity(Gravity.CENTER);
        tab.setSingleLine();

        addTab(position, tab);
    }
 
Example 14
Source File: DrawerUserCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public DrawerUserCell(Context context) {
    super(context);

    avatarDrawable = new AvatarDrawable();
    avatarDrawable.setTextSize(AndroidUtilities.dp(12));

    imageView = new BackupImageView(context);
    imageView.setRoundRadius(AndroidUtilities.dp(18));
    addView(imageView, LayoutHelper.createFrame(36, 36, Gravity.LEFT | Gravity.TOP, 14, 6, 0, 0));

    textView = new TextView(context);
    textView.setTextColor(Theme.getColor(Theme.key_chats_menuItemText));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 72, 0, 60, 0));

    checkBox = new GroupCreateCheckBox(context);
    checkBox.setChecked(true, false);
    checkBox.setCheckScale(0.9f);
    checkBox.setInnerRadDiff(AndroidUtilities.dp(1.5f));
    checkBox.setColorKeysOverrides(Theme.key_chats_unreadCounterText, Theme.key_chats_unreadCounter, Theme.key_chats_menuBackground);
    addView(checkBox, LayoutHelper.createFrame(18, 18, Gravity.LEFT | Gravity.TOP, 37, 27, 0, 0));

    setWillNotDraw(false);
}
 
Example 15
Source File: PhonebookShareAlert.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public TextCheckBoxCell(Context context) {
    super(context);

    textView = new TextView(context);
    textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setSingleLine(false);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    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 ? (isImport ? 17 : 64) : 72, 10, LocaleController.isRTL ? 72 : (isImport ? 17 : 64), 0));

    valueTextView = new TextView(context);
    valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    valueTextView.setLines(1);
    valueTextView.setMaxLines(1);
    valueTextView.setSingleLine(true);
    valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, LocaleController.isRTL ? (isImport ? 17 : 64) : 72, 35, LocaleController.isRTL ? 72 : (isImport ? 17 : 64), 0));

    imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayIcon), PorterDuff.Mode.MULTIPLY));
    addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 20, 20, LocaleController.isRTL ? 20 : 0, 0));

    if (!isImport) {
        checkBox = new Switch(context);
        checkBox.setColors(Theme.key_switchTrack, Theme.key_switchTrackChecked, Theme.key_windowBackgroundWhite, Theme.key_windowBackgroundWhite);
        addView(checkBox, LayoutHelper.createFrame(37, 40, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 22, 0, 22, 0));
    }
}
 
Example 16
Source File: PagerTitleStrip.java    From android-recipes-app with Apache License 2.0 4 votes vote down vote up
public void setSingleLineAllCaps(TextView text) {
    text.setSingleLine();
}
 
Example 17
Source File: FeaturedStickerSetInfoCell.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public FeaturedStickerSetInfoCell(Context context, int left, boolean supportRtl, boolean canAddRemove) {
    super(context);
    this.canAddRemove = canAddRemove;

    FrameLayout.LayoutParams lp;

    nameTextView = new TextView(context);
    nameTextView.setTextColor(Theme.getColor(Theme.key_chat_emojiPanelTrendingTitle));
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setSingleLine(true);
    if (supportRtl) {
        lp = LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.START, left, 8, 40, 0);
    } else {
        lp = LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, left, 8, 40, 0);
    }
    addView(nameTextView, lp);

    infoTextView = new TextView(context);
    infoTextView.setTextColor(Theme.getColor(Theme.key_chat_emojiPanelTrendingDescription));
    infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    infoTextView.setEllipsize(TextUtils.TruncateAt.END);
    infoTextView.setSingleLine(true);
    if (supportRtl) {
        lp = LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.START, left, 30, 100, 0);
    } else {
        lp = LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, left, 30, 100, 0);
    }
    addView(infoTextView, lp);

    if (canAddRemove) {
        addButton = new ProgressButton(context);
        addButton.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText));
        addButton.setText(LocaleController.getString("Add", R.string.Add));
        if (supportRtl) {
            lp = LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, 28, Gravity.TOP | Gravity.END, 0, 16, 14, 0);
        } else {
            lp = LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 28, Gravity.TOP | Gravity.RIGHT, 0, 16, 14, 0);
        }
        addView(addButton, lp);

        delButton = new TextView(context);
        delButton.setGravity(Gravity.CENTER);
        delButton.setTextColor(Theme.getColor(Theme.key_featuredStickers_removeButtonText));
        delButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
        delButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
        delButton.setText(LocaleController.getString("StickersRemove", R.string.StickersRemove));
        if (supportRtl) {
            lp = LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, 28, Gravity.TOP | Gravity.END, 0, 16, 14, 0);
        } else {
            lp = LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 28, Gravity.TOP | Gravity.RIGHT, 0, 16, 14, 0);
        }
        addView(delButton, lp);
    }

    setWillNotDraw(false);
    updateColors();
}
 
Example 18
Source File: ViewMaker.java    From iGap-Android with GNU Affero General Public License v3.0 4 votes vote down vote up
static View getVideoItem(boolean withText) {

        LinearLayout mainContainer = new LinearLayout(G.context);
        mainContainer.setId(R.id.mainContainer);
        mainContainer.setOrientation(HORIZONTAL);
        LinearLayout.LayoutParams layout_882 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        mainContainer.setLayoutParams(layout_882);

        LinearLayout linearLayout_223 = new LinearLayout(G.context);
        linearLayout_223.setOrientation(VERTICAL);
        LinearLayout.LayoutParams layout_509 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        linearLayout_223.setLayoutParams(layout_509);

        LinearLayout contentContainer = new LinearLayout(G.context);
        LinearLayout.LayoutParams layout_5095 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        contentContainer.setPadding(i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp4));
        contentContainer.setLayoutParams(layout_5095);
        contentContainer.setId(R.id.contentContainer);

        LinearLayout m_container = new LinearLayout(G.context);
        m_container.setId(R.id.m_container);
        m_container.setOrientation(VERTICAL);
        LinearLayout.LayoutParams layout_518 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        m_container.setLayoutParams(layout_518);

        FrameLayout frameLayout_642 = new FrameLayout(G.context);
        LinearLayout.LayoutParams layout_535 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        frameLayout_642.setLayoutParams(layout_535);

        ReserveSpaceRoundedImageView thumbnail = new ReserveSpaceRoundedImageView(G.context);
        thumbnail.setId(R.id.thumbnail);
        FrameLayout.LayoutParams layout_679 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        thumbnail.setLayoutParams(layout_679);
        thumbnail.setScaleType(ImageView.ScaleType.FIT_XY);
        thumbnail.setCornerRadius((int) G.context.getResources().getDimension(R.dimen.messageBox_cornerRadius));
        frameLayout_642.addView(thumbnail);

        TextView duration = new TextView(G.context);
        duration.setId(R.id.duration);
        duration.setBackgroundResource(R.drawable.bg_message_image_time);
        duration.setGravity(Gravity.CENTER_VERTICAL);
        duration.setSingleLine(true);
        duration.setPadding(i_Dp(R.dimen.dp4), dpToPixel(1), i_Dp(R.dimen.dp4), dpToPixel(1));
        duration.setText("3:48 (4.5 MB)");
        duration.setAllCaps(TRUE);
        duration.setTextColor(G.context.getResources().getColor(R.color.gray10));
        setTextSize(duration, R.dimen.dp10);
        setTypeFace(duration);
        FrameLayout.LayoutParams layout_49 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layout_49.gravity = Gravity.LEFT | Gravity.TOP;
        layout_49.bottomMargin = -dpToPixel(2);
        layout_49.leftMargin = dpToPixel(5);
        layout_49.topMargin = dpToPixel(7);
        duration.setLayoutParams(layout_49);
        frameLayout_642.addView(duration);

        frameLayout_642.addView(getProgressBar(0), new FrameLayout.LayoutParams(i_Dp(R.dimen.dp48), i_Dp(R.dimen.dp48), Gravity.CENTER));

        m_container.addView(frameLayout_642);

        if (withText) {
            m_container.addView(getTextView());
        }

        contentContainer.addView(m_container);
        linearLayout_223.addView(contentContainer);
        mainContainer.addView(linearLayout_223);

        return mainContainer;
    }
 
Example 19
Source File: NumberPicker.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void init() {
    mSolidColor = 0;
    mSelectionDivider = new Paint();
    mSelectionDivider.setColor(Theme.getColor(Theme.key_dialogButton));

    mSelectionDividerHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, UNSCALED_DEFAULT_SELECTION_DIVIDER_HEIGHT, getResources().getDisplayMetrics());
    mSelectionDividersDistance = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, UNSCALED_DEFAULT_SELECTION_DIVIDERS_DISTANCE, getResources().getDisplayMetrics());

    mMinHeight = SIZE_UNSPECIFIED;

    mMaxHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 180, getResources().getDisplayMetrics());
    if (mMinHeight != SIZE_UNSPECIFIED && mMaxHeight != SIZE_UNSPECIFIED && mMinHeight > mMaxHeight) {
        throw new IllegalArgumentException("minHeight > maxHeight");
    }

    mMinWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 64, getResources().getDisplayMetrics());

    mMaxWidth = SIZE_UNSPECIFIED;
    if (mMinWidth != SIZE_UNSPECIFIED && mMaxWidth != SIZE_UNSPECIFIED && mMinWidth > mMaxWidth) {
        throw new IllegalArgumentException("minWidth > maxWidth");
    }

    mComputeMaxWidth = (mMaxWidth == SIZE_UNSPECIFIED);

    mPressedStateHelper = new PressedStateHelper();

    setWillNotDraw(false);

    mInputText = new TextView(getContext());
    mInputText.setGravity(Gravity.CENTER);
    mInputText.setSingleLine(true);
    mInputText.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    mInputText.setBackgroundResource(0);
    mInputText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    mInputText.setVisibility(INVISIBLE);
    addView(mInputText, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));

    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity() / SELECTOR_MAX_FLING_VELOCITY_ADJUSTMENT;
    mTextSize = (int) mInputText.getTextSize();

    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setTextAlign(Align.CENTER);
    paint.setTextSize(mTextSize);
    paint.setTypeface(mInputText.getTypeface());
    ColorStateList colors = mInputText.getTextColors();
    int color = colors.getColorForState(ENABLED_STATE_SET, Color.WHITE);
    paint.setColor(color);
    mSelectorWheelPaint = paint;

    mFlingScroller = new Scroller(getContext(), null, true);
    mAdjustScroller = new Scroller(getContext(), new DecelerateInterpolator(2.5f));

    updateInputTextView();
}
 
Example 20
Source File: FeaturedStickerSetCell2.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public FeaturedStickerSetCell2(Context context) {
    super(context);

    textView = new TextView(context);
    textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    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);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, LocaleController.isRTL ? 22 : 71, 10, LocaleController.isRTL ? 71 : 22, 0));

    valueTextView = new TextView(context);
    valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    valueTextView.setLines(1);
    valueTextView.setMaxLines(1);
    valueTextView.setSingleLine(true);
    valueTextView.setEllipsize(TextUtils.TruncateAt.END);
    valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, LocaleController.isRTL ? 100 : 71, 35, LocaleController.isRTL ? 71 : 100, 0));

    imageView = new BackupImageView(context);
    imageView.setAspectFit(true);
    imageView.setLayerNum(1);
    addView(imageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 12, 8, LocaleController.isRTL ? 12 : 0, 0));

    addButton = new ProgressButton(context);
    addButton.setText(LocaleController.getString("Add", R.string.Add));
    addButton.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText));
    addView(addButton, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, 28, Gravity.TOP | Gravity.END, 0, 18, 14, 0));

    delButton = new TextView(context);
    delButton.setGravity(Gravity.CENTER);
    delButton.setTextColor(Theme.getColor(Theme.key_featuredStickers_removeButtonText));
    delButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    delButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    delButton.setText(LocaleController.getString("StickersRemove", R.string.StickersRemove));
    addView(delButton, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, 28, Gravity.TOP | Gravity.END, 0, 16, 14, 0));

    updateColors();
}