Java Code Examples for android.widget.TextView.setMaxLines()

The following are Jave code examples for showing how to use setMaxLines() of the android.widget.TextView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: PlusGram   File: ShareDialogCell.java   View Source Code Vote up 6 votes
public ShareDialogCell(Context context) {
    super(context);
    setBackgroundResource(R.drawable.list_selector);

    imageView = new BackupImageView(context);
    imageView.setRoundRadius(AndroidUtilities.dp(27));
    addView(imageView, LayoutHelper.createFrame(54, 54, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 7, 0, 0));
    SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
    int nColor = themePrefs.getInt("chatAttachTextColor", 0xff757575);
    nameTextView = new TextView(context);
    //nameTextView.setTextColor(0xff212121);
    nameTextView.setTextColor(nColor != 0xff757575 ? nColor : 0xff212121);
    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, 64, 6, 0));

    checkBox = new CheckBox(context, R.drawable.round_check2);
    checkBox.setSize(24);
    checkBox.setCheckOffset(AndroidUtilities.dp(1));
    checkBox.setVisibility(VISIBLE);
    checkBox.setColor(0xff3ec1f9);
    addView(checkBox, LayoutHelper.createFrame(24, 24, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 17, 39, 0, 0));
}
 
Example 2
Project: PlusGram   File: JoinSheetUserCell.java   View Source Code Vote up 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(0xff212121);
    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 3
Project: ChenYan   File: ClickShowMoreLayout.java   View Source Code Vote up 6 votes
private void initView(Context context) {
    mTextView = new TextView(context);
    mClickToShow = new TextView(context);

    mTextView.setTextSize(textSize);
    mTextView.setTextColor(textColor);
    mTextView.setMaxLines(showLine);

    mClickToShow.setBackground(getResources().getDrawable(R.drawable.selector_tx_show_more));
    mClickToShow.setTextSize(textSize);
    mClickToShow.setTextColor(getResources().getColor(R.color.nick));
    mClickToShow.setText(clickText);

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    params.topMargin = UIHelper.dipToPx(10f);
    mClickToShow.setLayoutParams(params);
    mClickToShow.setOnClickListener(this);

    setOrientation(VERTICAL);
    addView(mTextView);
    addView(mClickToShow);
}
 
Example 4
Project: airgram   File: ChatAttachAlert.java   View Source Code Vote up 6 votes
public AttachBotButton(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.setTypeface(FontManager.instance().getTypeface());
    nameTextView.setTextColor(Theme.ATTACH_SHEET_TEXT_COLOR);
    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, 65, 6, 0));
}
 
Example 5
Project: AliZhiBoHao   File: LiveCameraActivity.java   View Source Code Vote up 6 votes
public void addView(TextView childView, String text) {
    if (push_state_ll.getChildCount() > 3) {
        push_state_ll.removeViewAt(0);
    }
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(0, 0, 0, 10);
    childView.setTextColor(Color.RED);
    childView.setText(text);
    childView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13f);
    childView.setBackgroundResource(R.drawable.text_state);
    childView.setLayoutParams(layoutParams);
    childView.setPadding(15, 10, 15, 10);
    childView.setMaxEms(20);
    childView.setMaxLines(3);
    push_state_ll.addView(childView);
}
 
Example 6
Project: smart-asset-iot-android-demo   File: MainActivity.java   View Source Code Vote up 5 votes
private void showSnackBar(String text) {
    Snackbar snackbar = Snackbar.make(buttonContainer,
            text,
            Snackbar.LENGTH_INDEFINITE);
    View snackbarView = snackbar.getView();
    snackbarView.setBackgroundColor(ContextCompat.getColor(this, R.color.snackbar_color));
    snackbar.setActionTextColor(ContextCompat.getColor(this, R.color.white));
    TextView textView = snackbarView.findViewById(android.support.design.R.id.snackbar_text);
    textView.setMaxLines(10);
    snackbar.setAction(getString(R.string.dismiss), view1 -> snackbar.dismiss());
    snackbar.show();
}
 
Example 7
Project: AdaptiveTableLayout   File: TableLayoutFragment.java   View Source Code Vote up 5 votes
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mSnackbar = Snackbar.make(view, R.string.changes_saved, Snackbar.LENGTH_INDEFINITE);
    TextView tv = (TextView) mSnackbar.getView().findViewById(android.support.design.R.id.snackbar_text);
    tv.setMaxLines(3);
    mSnackbar.setAction("Close", new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mSnackbar.dismiss();
        }
    });
}
 
Example 8
Project: aos-Video   File: FullTextRowPresenter.java   View Source Code Vote up 5 votes
public FullTextRowViewHolder(ViewHolder parentViewHolder, View contentView) {
    super(parentViewHolder.view);

    mFullWidthViewHolder = parentViewHolder;
    mTextTv = (TextView)contentView.findViewById(R.id.text);
    if (mMaxLines>0) {
        mTextTv.setMaxLines(mMaxLines);
        mTextTv.setEllipsize(TextUtils.TruncateAt.END);
    }
}
 
Example 9
Project: container   File: RemoteViewsUtils.java   View Source Code Vote up 5 votes
private void fixTextView(ViewGroup viewGroup) {
	int count = viewGroup.getChildCount();
	for (int i = 0; i < count; i++) {
		View v = viewGroup.getChildAt(i);
		if (v instanceof TextView) {
			TextView tv = (TextView) v;
			if (isSingleLine(tv)) {
				tv.setSingleLine(false);
				tv.setMaxLines(1);
			}
		} else if (v instanceof ViewGroup) {
			fixTextView((ViewGroup) v);
		}
	}
}
 
Example 10
Project: PlusGram   File: PhotoPickerAlbumsCell.java   View Source Code Vote up 5 votes
public AlbumView(Context context) {
    super(context);

    imageView = new BackupImageView(context);
    addView(imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setBackgroundColor(0x7f000000);
    addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 28, Gravity.LEFT | Gravity.BOTTOM));

    nameTextView = new TextView(context);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    nameTextView.setTextColor(0xffffffff);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setMaxLines(1);
    nameTextView.setGravity(Gravity.CENTER_VERTICAL);
    linearLayout.addView(nameTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 8, 0, 0, 0));

    countTextView = new TextView(context);
    countTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    countTextView.setTextColor(0xffaaaaaa);
    countTextView.setSingleLine(true);
    countTextView.setEllipsize(TextUtils.TruncateAt.END);
    countTextView.setMaxLines(1);
    countTextView.setGravity(Gravity.CENTER_VERTICAL);
    linearLayout.addView(countTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, 4, 0, 4, 0));

    selector = new View(context);
    selector.setBackgroundResource(R.drawable.list_selector);
    addView(selector, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
}
 
Example 11
Project: KrGallery   File: PhotoPickerAlbumsCell.java   View Source Code Vote up 5 votes
public AlbumView(Context context) {
    super(context);

    imageView = new BackupImageView(context);
    addView(imageView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setBackgroundColor(0x7f000000);
    addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 28,
            Gravity.LEFT | Gravity.BOTTOM));

    nameTextView = new TextView(context);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    nameTextView.setTextColor(0xffffffff);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setMaxLines(1);
    nameTextView.setGravity(Gravity.CENTER_VERTICAL);
    linearLayout.addView(nameTextView,
            LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 8, 0, 0, 0));

    countTextView = new TextView(context);
    countTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    countTextView.setTextColor(0xffaaaaaa);
    countTextView.setSingleLine(true);
    countTextView.setEllipsize(TextUtils.TruncateAt.END);
    countTextView.setMaxLines(1);
    countTextView.setGravity(Gravity.CENTER_VERTICAL);
    linearLayout.addView(countTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT,
            LayoutHelper.MATCH_PARENT, 4, 0, 4, 0));

    selector = new View(context);
    selector.setBackgroundResource(R.drawable.list_selector);
    addView(selector,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
}
 
Example 12
Project: Google-Developer-Challenge-Scholarship-Android-Basics   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    TextView textView = new TextView(this);
    textView.setText("Google Developer Challenge Scholarship - Android Basics");
    textView.setTextSize(56);
    textView.setTextColor(Color.GREEN);
    textView.setMaxLines(2);

    setContentView(textView);
}
 
Example 13
Project: aos-Video   File: TorrentBlocklistDialogPreference.java   View Source Code Vote up 5 votes
@Override
protected void onBindView(View view)
{       
	super.onBindView(view);

	TextView summary= (TextView)view.findViewById(android.R.id.summary);
	summary.setMaxLines(1); //only one line for pref
}
 
Example 14
Project: PlusGram   File: TextDetailCell.java   View Source Code Vote up 5 votes
public TextDetailCell(Context context) {
    super(context);

    textView = new TextView(context);
    textView.setTextColor(0xff212121);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setSingleLine(true);
    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(0xff8a8a8a);
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    valueTextView.setLines(1);
    valueTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    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);
    addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 0 : 16, 0, LocaleController.isRTL ? 16 : 0, 0));
}
 
Example 15
Project: airgram   File: BotSwitchCell.java   View Source Code Vote up 5 votes
public BotSwitchCell(Context context) {
    super(context);
    setBackgroundResource(R.drawable.list_selector);

    textView = new TextView(context);
    textView.setTypeface(FontManager.instance().getTypeface());
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    textView.setTextColor(0xff4391cc);
    textView.setTypeface(FontManager.instance().getTypeface());
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setMaxLines(1);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
    addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), 14, 0, 14, 0));
}
 
Example 16
Project: TPlayer   File: RemoteViewsFixer.java   View Source Code Vote up 5 votes
private void fixTextView(ViewGroup viewGroup) {
    int count = viewGroup.getChildCount();
    for (int i = 0; i < count; i++) {
        View v = viewGroup.getChildAt(i);
        if (v instanceof TextView) {
            TextView tv = (TextView) v;
            if (isSingleLine(tv)) {
                tv.setSingleLine(false);
                tv.setMaxLines(1);
            }
        } else if (v instanceof ViewGroup) {
            fixTextView((ViewGroup) v);
        }
    }
}
 
Example 17
Project: RLibrary   File: UITitleBarContainer.java   View Source Code Vote up 5 votes
private TextView createTextItem(String text, @ColorInt int color) {
    TextView item = new RTextView(getContext());
    int padding = getResources().getDimensionPixelOffset(R.dimen.base_ldpi);
    item.setPadding(padding, 0, padding, 0);
    item.setText(text);
    item.setSingleLine();
    item.setMaxLines(1);
    item.setTextSize(TypedValue.COMPLEX_UNIT_PX, SkinHelper.getSkin().getSubTextSize() /*getResources().getDimensionPixelOffset(R.dimen.base_title_size)*/);
    item.setTextColor(color == -1 ? Color.WHITE : color);
    item.setGravity(Gravity.CENTER);
    return item;
}
 
Example 18
Project: AstronomyTourPadova   File: Utils.java   View Source Code Vote up 5 votes
public static Snackbar showSnackbar(View view, String message, String action, View.OnClickListener listener) {
    Snackbar snackbar = Snackbar.make(view, message, Snackbar.LENGTH_INDEFINITE).setActionTextColor(view.getContext().getResources().getColor(R.color.fab_color)).setAction(action, listener);

    View snackbarView = snackbar.getView();
    TextView textView = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text);
    textView.setMaxLines(5);//this is your max line as your want
    snackbar.show();

    return snackbar;
}
 
Example 19
Project: Bailan   File: FoldingTextView.java   View Source Code Vote up 5 votes
/**
 * Title的高度(更新 应用介绍 权限 这几个字) 宽度是固定的MeasureSpec.EXACTLY
 *
 * @return
 */
public int getTileHeight() {
    int measuredWidth = titleTextView.getMeasuredWidth();
    TextView copyTextView = new TextView(getContext());
    copyTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    int widthMeasureSpec = MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY);
    copyTextView.setMaxLines(1);
    copyTextView.setLines(1);
    int heightMeasureSpec = MeasureSpec.makeMeasureSpec(2000, MeasureSpec.AT_MOST);//MeasureSpec.AT_MOST情况下前一个参数设置多少无所谓
    copyTextView.measure(widthMeasureSpec, heightMeasureSpec);
    return copyTextView.getMeasuredHeight();
}
 
Example 20
Project: TestChat   File: UrlTextView.java   View Source Code Vote up 5 votes
private void initView() {
        setOrientation(VERTICAL);
        LayoutInflater.from(getContext()).inflate(R.layout.share_fragment_item_content_layout, this);
        contentText = (TextView) findViewById(R.id.tv_url_text_content);
        contentText.setTextSize(PixelUtil.dp2px(16));
        contentText.setTextColor(getResources().getColor(R.color.base_color_text_black));
        cover = (TextView) findViewById(R.id.tv_url_text_cover);
        cover.setTextColor(getResources().getColor(R.color.base_color_text_black));
        contentText.setMaxLines(maxLine);
        cover.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                        if (cover.getText().toString().trim().equals("全文")) {
                                contentText.setMaxLines(Integer.MAX_VALUE);
                                cover.setText("收起");
                                if (mOnTextExpandStatusChangeListener != null) {
                                        mOnTextExpandStatusChangeListener.onExpandStatusChanged(false);
                                }
                        } else if (cover.getText().toString().trim().equals("收起")) {
                                contentText.setMaxLines(maxLine);
                                cover.setText("全文");
                                if (mOnTextExpandStatusChangeListener != null) {
                                        mOnTextExpandStatusChangeListener.onExpandStatusChanged(true);
                                }
                        }
                }
        });
}