Java Code Examples for android.widget.TextView#setMaxLines()
The following examples show how to use
android.widget.TextView#setMaxLines() .
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: DialogAdapter.java From YCDialog with Apache License 2.0 | 6 votes |
TopHolder(View view) { super(view); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.width = getScreenWidth(context) / 5; item = new TextView(view.getContext()); item.setLayoutParams(params); item.setMaxLines(1); item.setEllipsize(TextUtils.TruncateAt.END); item.setGravity(Gravity.CENTER); item.setTextColor(ContextCompat.getColor(view.getContext(), R.color.gray_dark)); item.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources().getDimension(R.dimen.app_normal_margin)); item.setCompoundDrawablePadding(topPadding); item.setPadding(0, padding, 0, padding); TypedValue typedValue = new TypedValue(); view.getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true); item.setBackgroundResource(typedValue.resourceId); ((LinearLayout) view).addView(item); }
Example 2
Source File: FormLayoutHelpers.java From commcare-android with Apache License 2.0 | 6 votes |
public static boolean determineNumberOfValidGroupLines(FormEntryActivity activity, Rect newRootViewDimensions, boolean hasGroupLabel, boolean shouldHideGroupLabel) { FrameLayout header = activity.findViewById(R.id.form_entry_header); TextView groupLabel = header.findViewById(R.id.form_entry_group_label); int numberOfGroupLinesAllowed = getNumberOfGroupLinesAllowed(groupLabel, newRootViewDimensions, activity); if (TextViewCompat.getMaxLines(groupLabel) != numberOfGroupLinesAllowed) { shouldHideGroupLabel = numberOfGroupLinesAllowed == 0; groupLabel.setMaxLines(numberOfGroupLinesAllowed); updateGroupViewVisibility(header, groupLabel, hasGroupLabel, shouldHideGroupLabel); } return shouldHideGroupLabel; }
Example 3
Source File: TextDetailCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public TextDetailCell(Context context) { super(context); textView = new TextView(context); textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); 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 ? 16 : 71, 10, LocaleController.isRTL ? 71 : 16, 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 ? 16 : 71, 35, LocaleController.isRTL ? 71 : 16, 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 : 16, 11, LocaleController.isRTL ? 16 : 0, 0)); }
Example 4
Source File: TextPriceCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public TextPriceCell(Context context) { super(context); dotstring = LocaleController.isRTL ? " ." : ". "; 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, 17, 0, 17, 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, 17, 0, 17, 0)); }
Example 5
Source File: JoinSheetUserCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public JoinSheetUserCell(Context context) { super(context); imageView = new BackupImageView(context); imageView.setRoundRadius(AndroidUtilities.dp(27)); addView(imageView, LayoutHelper.createFrame(54, 54, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 7, 0, 0)); nameTextView = new TextView(context); nameTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); nameTextView.setMaxLines(1); 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, 64, 6, 0)); }
Example 6
Source File: PhotoEditToolCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public PhotoEditToolCell(Context context) { super(context); nameTextView = new TextView(context); nameTextView.setGravity(Gravity.RIGHT); nameTextView.setTextColor(0xffffffff); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); nameTextView.setMaxLines(1); nameTextView.setSingleLine(true); nameTextView.setEllipsize(TextUtils.TruncateAt.END); addView(nameTextView, LayoutHelper.createFrame(80, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 0, 0, 0, 0)); valueTextView = new TextView(context); valueTextView.setTextColor(0xff6cc3ff); valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); valueTextView.setGravity(Gravity.RIGHT); valueTextView.setSingleLine(true); addView(valueTextView, LayoutHelper.createFrame(80, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 0, 0, 0, 0)); seekBar = new PhotoEditorSeekBar(context); addView(seekBar, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 40, Gravity.LEFT | Gravity.CENTER_VERTICAL, 96, 0, 24, 0)); }
Example 7
Source File: TextCheckCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public TextCheckCell(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.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(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2)); 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); addView(checkBox, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 14, 0, 14, 0)); }
Example 8
Source File: TextCheckCell2.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public TextCheckCell2(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.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(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2)); 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 Switch2(context); addView(checkBox, LayoutHelper.createFrame(44, 40, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 14, 0, 14, 0)); }
Example 9
Source File: ShareDialogCell.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public ShareDialogCell(Context context) { super(context); setWillNotDraw(false); imageView = new BackupImageView(context); imageView.setRoundRadius(AndroidUtilities.dp(28)); addView(imageView, LayoutHelper.createFrame(56, 56, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 7, 0, 0)); nameTextView = new TextView(context); nameTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); nameTextView.setMaxLines(2); nameTextView.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL); nameTextView.setLines(2); nameTextView.setEllipsize(TextUtils.TruncateAt.END); addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 6, 66, 6, 0)); checkBox = new CheckBox2(context, 21); checkBox.setColor(Theme.key_dialogRoundCheckBox, Theme.key_dialogBackground, Theme.key_dialogRoundCheckBoxCheck); checkBox.setDrawUnchecked(false); checkBox.setDrawBackgroundAsArc(4); checkBox.setProgressDelegate(progress -> { float scale = 1.0f - (1.0f - 0.857f) * checkBox.getProgress(); imageView.setScaleX(scale); imageView.setScaleY(scale); }); addView(checkBox, LayoutHelper.createFrame(24, 24, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 19, 42, 0, 0)); }
Example 10
Source File: DialogBuilder.java From BlackList with Apache License 2.0 | 5 votes |
/** * Sets the title of the dialog **/ public DialogBuilder setTitle(String title, int maxLines) { TextView titleView = (TextView) getView().findViewById(R.id.dialog_title); titleView.setText(title); titleView.setMaxLines(maxLines); titleView.setEllipsize(TextUtils.TruncateAt.END); if (maxLines == 1) { titleView.setSingleLine(true); } titleView.setVisibility(View.VISIBLE); View lineView = getView().findViewById(R.id.title_line); lineView.setVisibility(View.VISIBLE); return this; }
Example 11
Source File: TextMessagePreference.java From 365browser with Apache License 2.0 | 5 votes |
@Override protected void onBindView(View view) { super.onBindView(view); TextView textView = (TextView) view.findViewById(android.R.id.title); textView.setSingleLine(false); textView.setMaxLines(Integer.MAX_VALUE); textView.setMovementMethod(LinkMovementMethod.getInstance()); }
Example 12
Source File: RadioButtonCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public RadioButtonCell(Context context) { super(context); radioButton = new RadioButton(context); radioButton.setSize(AndroidUtilities.dp(20)); 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 : 18), 10, (LocaleController.isRTL ? 18 : 0), 0)); 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.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), 10, (LocaleController.isRTL ? 51 : 17), 0)); valueTextView = new TextView(context); 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 : 51), 35, (LocaleController.isRTL ? 51 : 17), 0)); }
Example 13
Source File: LanguageCell.java From Telegram with GNU General Public License v2.0 | 5 votes |
public LanguageCell(Context context, boolean dialog) { super(context); setWillNotDraw(false); isDialog = dialog; textView = new TextView(context); textView.setTextColor(Theme.getColor(dialog ? 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.TOP); addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 23 + 48 : 23, (isDialog ? 4 : 7), LocaleController.isRTL ? 23 : 23 + 48, 0)); textView2 = new TextView(context); textView2.setTextColor(Theme.getColor(dialog ? Theme.key_dialogTextGray3 : Theme.key_windowBackgroundWhiteGrayText3)); textView2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); textView2.setLines(1); textView2.setMaxLines(1); textView2.setSingleLine(true); textView2.setEllipsize(TextUtils.TruncateAt.END); textView2.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); addView(textView2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 23 + 48 : 23, (isDialog ? 25 : 29), LocaleController.isRTL ? 23 : 23 + 48, 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, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 23, 0, 23, 0)); }
Example 14
Source File: ThemeCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public ThemeCell(Context context, boolean nightTheme) { super(context); setWillNotDraw(false); isNightTheme = nightTheme; paint = new Paint(Paint.ANTI_ALIAS_FLAG); textView = new TextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLines(1); textView.setMaxLines(1); textView.setSingleLine(true); textView.setPadding(0, 0, 0, AndroidUtilities.dp(1)); 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 ? 53 + 48 : 60, 0, LocaleController.isRTL ? 60 : 53 + 48, 0)); checkImage = new ImageView(context); checkImage.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_featuredStickers_addedIcon), PorterDuff.Mode.MULTIPLY)); checkImage.setImageResource(R.drawable.sticker_added); if (!isNightTheme) { addView(checkImage, LayoutHelper.createFrame(19, 14, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 17 + 38, 0, 17 + 38, 0)); optionsButton = new ImageView(context); optionsButton.setFocusable(false); optionsButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_stickers_menuSelector))); optionsButton.setImageResource(R.drawable.ic_ab_other); optionsButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_stickers_menu), PorterDuff.Mode.MULTIPLY)); optionsButton.setScaleType(ImageView.ScaleType.CENTER); addView(optionsButton, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP)); } else { addView(checkImage, LayoutHelper.createFrame(19, 14, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 17, 0, 17, 0)); } }
Example 15
Source File: DrawerActionCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public DrawerActionCell(Context context) { super(context); 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.setCompoundDrawablePadding(AndroidUtilities.dp(29)); addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 19, 0, 16, 0)); }
Example 16
Source File: FiltersSetupActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public SuggestedFilterCell(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, 22, 10, 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, 22, 35, 22, 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)); }
Example 17
Source File: PaymentRequestSection.java From 365browser with Apache License 2.0 | 4 votes |
/** * Updates the total and how it's broken down. * * @param cart The shopping cart contents and the total. */ public void update(ShoppingCart cart) { Context context = mBreakdownLayout.getContext(); CharSequence totalPrice = createValueString( cart.getTotal().getCurrency(), cart.getTotal().getPrice(), true); // Show the updated text view if the total changed. showUpdateIfTextChanged(totalPrice); // Update the summary to display information about the total. setSummaryText(cart.getTotal().getLabel(), totalPrice); mBreakdownLayout.removeAllViews(); if (cart.getContents() == null) return; int maximumDescriptionWidthPx = ((View) mBreakdownLayout.getParent()).getWidth() * 2 / 3; // Update the breakdown, using one row per {@link LineItem}. int numItems = cart.getContents().size(); mBreakdownLayout.setRowCount(numItems); for (int i = 0; i < numItems; i++) { LineItem item = cart.getContents().get(i); TextView description = new TextView(context); ApiCompatibilityUtils.setTextAppearance(description, item.getIsPending() ? R.style.PaymentsUiSectionPendingTextEndAligned : R.style.PaymentsUiSectionDescriptiveTextEndAligned); description.setText(item.getLabel()); description.setEllipsize(TruncateAt.END); description.setMaxLines(2); if (maximumDescriptionWidthPx > 0) { description.setMaxWidth(maximumDescriptionWidthPx); } TextView amount = new TextView(context); ApiCompatibilityUtils.setTextAppearance(amount, item.getIsPending() ? R.style.PaymentsUiSectionPendingTextEndAligned : R.style.PaymentsUiSectionDescriptiveTextEndAligned); amount.setText(createValueString(item.getCurrency(), item.getPrice(), false)); // Each item is represented by a row in the GridLayout. GridLayout.LayoutParams descriptionParams = new GridLayout.LayoutParams( GridLayout.spec(i, 1, GridLayout.END), GridLayout.spec(0, 1, GridLayout.END)); GridLayout.LayoutParams amountParams = new GridLayout.LayoutParams( GridLayout.spec(i, 1, GridLayout.END), GridLayout.spec(1, 1, GridLayout.END)); ApiCompatibilityUtils.setMarginStart(amountParams, context.getResources().getDimensionPixelSize( R.dimen.payments_section_descriptive_item_spacing)); mBreakdownLayout.addView(description, descriptionParams); mBreakdownLayout.addView(amount, amountParams); } }
Example 18
Source File: AudioCell.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public AudioCell(Context context) { super(context); playButton = new ImageView(context); addView(playButton, LayoutHelper.createFrame(46, 46, ((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP), LocaleController.isRTL ? 0 : 13, 13, LocaleController.isRTL ? 13 : 0, 0)); playButton.setOnClickListener(v -> { if (audioEntry != null) { if (MediaController.getInstance().isPlayingMessage(audioEntry.messageObject) && !MediaController.getInstance().isMessagePaused()) { MediaController.getInstance().pauseMessage(audioEntry.messageObject); setPlayDrawable(false); } else { ArrayList<MessageObject> arrayList = new ArrayList<>(); arrayList.add(audioEntry.messageObject); if (MediaController.getInstance().setPlaylist(arrayList, audioEntry.messageObject)) { setPlayDrawable(true); if (delegate != null) { delegate.startedPlayingAudio(audioEntry.messageObject); } } } } }); titleTextView = new TextView(context); titleTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); titleTextView.setLines(1); titleTextView.setMaxLines(1); titleTextView.setSingleLine(true); titleTextView.setEllipsize(TextUtils.TruncateAt.END); titleTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); addView(titleTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 50 : 72, 7, LocaleController.isRTL ? 72 : 50, 0)); genreTextView = new TextView(context); genreTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2)); genreTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); genreTextView.setLines(1); genreTextView.setMaxLines(1); genreTextView.setSingleLine(true); genreTextView.setEllipsize(TextUtils.TruncateAt.END); genreTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); addView(genreTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 50 : 72, 28, LocaleController.isRTL ? 72 : 50, 0)); authorTextView = new TextView(context); authorTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2)); authorTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); authorTextView.setLines(1); authorTextView.setMaxLines(1); authorTextView.setSingleLine(true); authorTextView.setEllipsize(TextUtils.TruncateAt.END); authorTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); addView(authorTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 50 : 72, 44, LocaleController.isRTL ? 72 : 50, 0)); timeTextView = new TextView(context); timeTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3)); timeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); timeTextView.setLines(1); timeTextView.setMaxLines(1); timeTextView.setSingleLine(true); timeTextView.setEllipsize(TextUtils.TruncateAt.END); timeTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP); addView(timeTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, LocaleController.isRTL ? 18 : 0, 11, LocaleController.isRTL ? 0 : 18, 0)); checkBox = new CheckBox(context, R.drawable.round_check2); checkBox.setVisibility(VISIBLE); checkBox.setColor(Theme.getColor(Theme.key_musicPicker_checkbox), Theme.getColor(Theme.key_musicPicker_checkboxCheck)); addView(checkBox, LayoutHelper.createFrame(22, 22, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, LocaleController.isRTL ? 18 : 0, 39, LocaleController.isRTL ? 0 : 18, 0)); }
Example 19
Source File: SharedDocumentCell.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public SharedDocumentCell(Context context) { super(context); TAG = DownloadController.getInstance(currentAccount).generateObserverTag(); placeholderImageView = new ImageView(context); addView(placeholderImageView, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 12, 8, LocaleController.isRTL ? 12 : 0, 0)); extTextView = new TextView(context); extTextView.setTextColor(Theme.getColor(Theme.key_files_iconText)); extTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); extTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); extTextView.setLines(1); extTextView.setMaxLines(1); extTextView.setSingleLine(true); extTextView.setGravity(Gravity.CENTER); extTextView.setEllipsize(TextUtils.TruncateAt.END); addView(extTextView, LayoutHelper.createFrame(32, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 16, 22, LocaleController.isRTL ? 16 : 0, 0)); thumbImageView = new BackupImageView(context); addView(thumbImageView, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 12, 8, LocaleController.isRTL ? 12 : 0, 0)); thumbImageView.getImageReceiver().setDelegate(new ImageReceiver.ImageReceiverDelegate() { @Override public void didSetImage(ImageReceiver imageReceiver, boolean set, boolean thumb) { extTextView.setVisibility(set ? INVISIBLE : VISIBLE); placeholderImageView.setVisibility(set ? INVISIBLE : VISIBLE); } }); nameTextView = new TextView(context); nameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); nameTextView.setLines(1); nameTextView.setMaxLines(1); nameTextView.setSingleLine(true); nameTextView.setEllipsize(TextUtils.TruncateAt.END); nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 8 : 72, 5, LocaleController.isRTL ? 72 : 8, 0)); statusImageView = new ImageView(context); statusImageView.setVisibility(INVISIBLE); statusImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_sharedMedia_startStopLoadIcon), PorterDuff.Mode.MULTIPLY)); addView(statusImageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 8 : 72, 35, LocaleController.isRTL ? 72 : 8, 0)); dateTextView = new TextView(context); dateTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3)); dateTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); dateTextView.setLines(1); dateTextView.setMaxLines(1); dateTextView.setSingleLine(true); dateTextView.setEllipsize(TextUtils.TruncateAt.END); dateTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(dateTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 8 : 72, 30, LocaleController.isRTL ? 72 : 8, 0)); progressView = new LineProgressView(context); progressView.setProgressColor(Theme.getColor(Theme.key_sharedMedia_startStopLoadIcon)); addView(progressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 2, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 72, 54, LocaleController.isRTL ? 72 : 0, 0)); checkBox = new CheckBox(context, R.drawable.round_check2); checkBox.setVisibility(INVISIBLE); checkBox.setColor(Theme.getColor(Theme.key_checkbox), Theme.getColor(Theme.key_checkboxCheck)); addView(checkBox, LayoutHelper.createFrame(22, 22, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 34, 30, LocaleController.isRTL ? 34 : 0, 0)); }
Example 20
Source File: ArchivedStickerSetCell.java From Telegram with GNU General Public License v2.0 | 4 votes |
public ArchivedStickerSetCell(Context context, boolean checkable) { super(context); if (this.checkable = checkable) { currentButton = 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)); final int minWidth = AndroidUtilities.dp(60); deleteButton = new ProgressButton(context); deleteButton.setAllCaps(false); deleteButton.setMinWidth(minWidth); deleteButton.setMinimumWidth(minWidth); deleteButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); deleteButton.setTextColor(Theme.getColor(Theme.key_featuredStickers_removeButtonText)); deleteButton.setText(LocaleController.getString("StickersRemove", R.string.StickersRemove)); deleteButton.setBackground(Theme.getRoundRectSelectorDrawable(Theme.getColor(Theme.key_featuredStickers_removeButtonText))); deleteButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); ViewHelper.setPadding(deleteButton, 8, 0, 8, 0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { deleteButton.setOutlineProvider(null); } addView(deleteButton, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, 28, Gravity.TOP | Gravity.END, 0, 18, 14, 0)); final OnClickListener toggleListener = v -> toggle(); addButton.setOnClickListener(toggleListener); deleteButton.setOnClickListener(toggleListener); syncButtons(false); } else { addButton = null; deleteButton = null; } 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(LayoutHelper.getAbsoluteGravityStart()); addView(textView, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START, 71, 10, 21, 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(LayoutHelper.getAbsoluteGravityStart()); addView(valueTextView, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START, 71, 35, 21, 0)); imageView = new BackupImageView(context); imageView.setAspectFit(true); imageView.setLayerNum(1); addView(imageView, LayoutHelper.createFrameRelatively(48, 48, Gravity.START | Gravity.TOP, 12, 8, 0, 0)); }