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

The following examples show how to use android.widget.TextView#setMinimumHeight() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: delion   File: NavigationPopup.java    License: Apache License 2.0 6 votes vote down vote up
public TextView createListItem() {
    TextView view = new TextView(mContext);
    view.setFadingEdgeLength(mFadeEdgeLength);
    view.setHorizontalFadingEdgeEnabled(true);
    view.setSingleLine();
    view.setTextSize(TEXT_SIZE_SP);
    view.setMinimumHeight(mListItemHeight);
    view.setGravity(Gravity.CENTER_VERTICAL);
    view.setCompoundDrawablePadding(mPadding);
    if (!mIsLayoutDirectionRTL) {
        view.setPadding(mPadding, 0, mPadding + mFadePadding , 0);
    } else {
        view.setPadding(mPadding + mFadePadding, 0, mPadding, 0);
    }
    return view;
}
 
Example 2
Source Project: AndroidChromium   File: NavigationPopup.java    License: Apache License 2.0 6 votes vote down vote up
public TextView createListItem() {
    TextView view = new TextView(mContext);
    view.setFadingEdgeLength(mFadeEdgeLength);
    view.setHorizontalFadingEdgeEnabled(true);
    view.setSingleLine();
    view.setTextSize(TEXT_SIZE_SP);
    view.setMinimumHeight(mListItemHeight);
    view.setGravity(Gravity.CENTER_VERTICAL);
    view.setCompoundDrawablePadding(mPadding);
    if (!mIsLayoutDirectionRTL) {
        view.setPadding(mPadding, 0, mPadding + mFadePadding , 0);
    } else {
        view.setPadding(mPadding + mFadePadding, 0, mPadding, 0);
    }
    return view;
}
 
Example 3
Source Project: 365browser   File: NavigationPopup.java    License: Apache License 2.0 6 votes vote down vote up
public TextView createListItem() {
    TextView view = new TextView(mContext);
    view.setFadingEdgeLength(mFadeEdgeLength);
    view.setHorizontalFadingEdgeEnabled(true);
    view.setSingleLine();
    view.setTextSize(TEXT_SIZE_SP);
    view.setMinimumHeight(mListItemHeight);
    view.setGravity(Gravity.CENTER_VERTICAL);
    view.setCompoundDrawablePadding(mPadding);
    if (!mIsLayoutDirectionRTL) {
        view.setPadding(mPadding, 0, mPadding + mFadePadding , 0);
    } else {
        view.setPadding(mPadding + mFadePadding, 0, mPadding, 0);
    }
    return view;
}
 
Example 4
public TextView createListItem() {
    TextView view = new TextView(mContext);
    view.setFadingEdgeLength(mFadeEdgeLength);
    view.setHorizontalFadingEdgeEnabled(true);
    view.setSingleLine();
    view.setTextSize(TEXT_SIZE_SP);
    view.setMinimumHeight(mListItemHeight);
    view.setGravity(Gravity.CENTER_VERTICAL);
    view.setCompoundDrawablePadding(mPadding);
    if (!mIsLayoutDirectionRTL) {
        view.setPadding(mPadding, 0, mPadding + mFadePadding , 0);
    }
    else {
        view.setPadding(mPadding + mFadePadding, 0, mPadding, 0);
    }
    return view;
}
 
Example 5
public TextView createListItem() {
    TextView view = new TextView(mContext);
    view.setFadingEdgeLength(mFadeEdgeLength);
    view.setHorizontalFadingEdgeEnabled(true);
    view.setSingleLine();
    view.setTextSize(TEXT_SIZE_SP);
    view.setMinimumHeight(mListItemHeight);
    view.setGravity(Gravity.CENTER_VERTICAL);
    view.setCompoundDrawablePadding(mPadding);
    if (!mIsLayoutDirectionRTL) {
        view.setPadding(mPadding, 0, mPadding + mFadePadding , 0);
    }
    else {
        view.setPadding(mPadding + mFadePadding, 0, mPadding, 0);
    }
    return view;
}
 
Example 6
@Override
public void handleMessage(Message msg) {
	super.handleMessage(msg);
	TextView textView = new TextView(ShowMagicDialogTestService.this);
	textView.setGravity(Gravity.CENTER);
	textView.setMinimumHeight(DisplayUtil.dpToPx(100));
	textView.setText("测试全局弹框");
	MagicDialog.show(ShowMagicDialogTestService.this, textView, false);
	//handler.sendEmptyMessageDelayed(0, 4000);
}
 
Example 7
Source Project: UIWidget   File: UIActionSheetDialog.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 创建Title
 */
private void createTitle() {
    if (TextUtils.isEmpty(mTitleStr)) {
        return;
    }
    mTvTitle = new TextView(mContext);
    mTvTitle.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mTvTitle.setMinimumHeight(dp2px(20));
    mTvTitle.setId(R.id.tv_titleActionSheetDialog);
    mLLayoutRoot.addView(mTvTitle);

    Drawable background = mStateDrawableSingle;
    mTvTitle.setLineSpacing(mLineSpacingExtra, mLineSpacingMultiplier);
    mTvTitle.setGravity(mTitleGravity);
    mTvTitle.setPadding(mItemsTextPaddingLeft, mItemsTextPaddingTop, mItemsTextPaddingRight, mItemsTextPaddingBottom);
    mTvTitle.setCompoundDrawablePadding(mTextDrawablePadding);
    mTvTitle.setText(mTitleStr);
    mTvTitle.setTextSize(mTextSizeUnit, mTitleTextSize);
    mTvTitle.setTextColor(mTitleTextColor);
    boolean hasList = mListItem != null && mListItem.size() > 0;
    boolean hasCancel = !TextUtils.isEmpty(mCancelStr) && mCancelMarginTop <= 0;
    if (hasList || hasCancel) {
        background = mStateDrawableTop.getCurrent();
    }
    setViewBackground(mTvTitle, DrawableUtil.getNewDrawable(background));
    setTextViewLine(mTvTitle);
}
 
Example 8
Source Project: UIWidget   File: UIActionSheetDialog.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 创建取消按钮
 */
private void createCancel() {
    if (TextUtils.isEmpty(mCancelStr)) {
        return;
    }
    mTvCancel = new TextView(mContext);
    mTvCancel.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mTvCancel.setMinimumHeight(mItemsMinHeight);
    mTvCancel.setId(R.id.tv_cancelActionSheetDialog);
    mLLayoutRoot.addView(mTvCancel);

    mTvCancel.setLineSpacing(mLineSpacingExtra, mLineSpacingMultiplier);
    mTvCancel.setGravity(mCancelGravity);
    mTvCancel.setCompoundDrawablePadding(mTextDrawablePadding);
    mTvCancel.setPadding(mItemsTextPaddingLeft, mItemsTextPaddingTop, mItemsTextPaddingRight, mItemsTextPaddingBottom);
    mTvCancel.setText(mCancelStr);
    mTvCancel.setTextSize(mTextSizeUnit, mCancelTextSize);
    mTvCancel.setTextColor(mCancelTextColor);
    if (mCancelMarginTop > 0) {
        ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) mTvCancel.getLayoutParams();
        if (lp != null) {
            lp.topMargin = mCancelMarginTop;
            mTvCancel.setLayoutParams(lp);
        }
    }
    boolean single = mCancelMarginTop > 0 || TextUtils.isEmpty(mTitleStr) && mViewItem == null || mBottomDrawable == null;
    setViewBackground(mTvCancel, DrawableUtil.getNewDrawable(single ? mStateDrawableSingle : mStateDrawableBottom));

    mTvCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mDialog.dismiss();
        }
    });
    setTextViewLine(mTvCancel);
}
 
Example 9
/**
 * Sets the minimum height of a text view.
 *
 * @param textview text view instance
 * @param minHeight minimum height of the text view in pixels
 */
public static void setMinHeight(TextView textview, int minHeight) {
  // According to https://developer.android.com/reference/android/widget/TextView.html#setMinHeight(int), the minimum
  // height of TextView is the maximum of setMinHeight and setMinimumHeight. Talk about NIH syndrome!
  textview.setMinHeight(minHeight);
  textview.setMinimumHeight(minHeight);
}
 
Example 10
Source Project: delion   File: PaymentRequestSection.java    License: Apache License 2.0 4 votes vote down vote up
private TextView createLabel(
        GridLayout parent, int rowIndex, boolean iconExists, boolean isEnabled) {
    Context context = parent.getContext();
    Resources resources = context.getResources();

    // By default, the label appears to the right of the "button" in the second column.
    // + If there is no button and no icon, the label spans the whole row.
    // + If there is no icon, the label spans two columns.
    // + Otherwise, the label occupies only its own column.
    int columnStart = 1;
    int columnSpan = iconExists ? 1 : 2;

    TextView labelView = new TextView(context);
    if (mRowType == OPTION_ROW_TYPE_OPTION) {
        // Show the string representing the PaymentOption.
        ApiCompatibilityUtils.setTextAppearance(labelView, isEnabled
                ? R.style.PaymentsUiSectionDefaultText
                : R.style.PaymentsUiSectionDisabledText);
        labelView.setText(convertOptionToString(mOption));
        labelView.setEnabled(isEnabled);
    } else if (mRowType == OPTION_ROW_TYPE_ADD) {
        // Shows string saying that the user can add a new option, e.g. credit card no.
        String typeface = resources.getString(R.string.roboto_medium_typeface);
        int textStyle = resources.getInteger(R.integer.roboto_medium_textstyle);
        int buttonHeight = resources.getDimensionPixelSize(
                R.dimen.payments_section_add_button_height);

        ApiCompatibilityUtils.setTextAppearance(
                labelView, R.style.PaymentsUiSectionAddButtonLabel);
        labelView.setMinimumHeight(buttonHeight);
        labelView.setGravity(Gravity.CENTER_VERTICAL);
        labelView.setTypeface(Typeface.create(typeface, textStyle));
    } else if (mRowType == OPTION_ROW_TYPE_DESCRIPTION) {
        // The description spans all the columns.
        columnStart = 0;
        columnSpan = 3;

        ApiCompatibilityUtils.setTextAppearance(
                labelView, R.style.PaymentsUiSectionDescriptiveText);
    } else if (mRowType == OPTION_ROW_TYPE_WARNING) {
        // Warnings use two columns.
        columnSpan = 2;
        ApiCompatibilityUtils.setTextAppearance(
                labelView, R.style.PaymentsUiSectionWarningText);
    }

    // The label spans two columns if no icon exists.  Setting the view width to 0
    // forces it to stretch.
    GridLayout.LayoutParams labelParams = new GridLayout.LayoutParams(
            GridLayout.spec(rowIndex, 1, GridLayout.CENTER),
            GridLayout.spec(columnStart, columnSpan, GridLayout.FILL));
    labelParams.topMargin = mVerticalMargin;
    labelParams.width = 0;
    parent.addView(labelView, labelParams);

    labelView.setOnClickListener(OptionSection.this);
    return labelView;
}
 
Example 11
private TextView createLabel(GridLayout parent, int rowIndex, boolean optionIconExists,
        boolean editIconExists, boolean isEnabled) {
    Context context = parent.getContext();
    Resources resources = context.getResources();

    // By default, the label appears to the right of the "button" in the second column.
    // + If there is no button, no option and edit icon, the label spans the whole row.
    // + If there is no option and edit icon, the label spans three columns.
    // + If there is no edit icon or option icon, the label spans two columns.
    // + Otherwise, the label occupies only its own column.
    int columnStart = 1;
    int columnSpan = 1;
    if (!optionIconExists) columnSpan++;
    if (!editIconExists) columnSpan++;

    TextView labelView = new TextView(context);
    if (mRowType == OPTION_ROW_TYPE_OPTION) {
        // Show the string representing the PaymentOption.
        ApiCompatibilityUtils.setTextAppearance(labelView, isEnabled
                ? R.style.PaymentsUiSectionDefaultText
                : R.style.PaymentsUiSectionDisabledText);
        labelView.setText(convertOptionToString(
                mOption, mDelegate.isBoldLabelNeeded(OptionSection.this)));
        labelView.setEnabled(isEnabled);
    } else if (mRowType == OPTION_ROW_TYPE_ADD) {
        // Shows string saying that the user can add a new option, e.g. credit card no.
        String typeface = resources.getString(R.string.roboto_medium_typeface);
        int textStyle = resources.getInteger(R.integer.roboto_medium_textstyle);
        int buttonHeight = resources.getDimensionPixelSize(
                R.dimen.payments_section_add_button_height);

        ApiCompatibilityUtils.setTextAppearance(
                labelView, R.style.PaymentsUiSectionAddButtonLabel);
        labelView.setMinimumHeight(buttonHeight);
        labelView.setGravity(Gravity.CENTER_VERTICAL);
        labelView.setTypeface(Typeface.create(typeface, textStyle));
    } else if (mRowType == OPTION_ROW_TYPE_DESCRIPTION) {
        // The description spans all the columns.
        columnStart = 0;
        columnSpan = 4;

        ApiCompatibilityUtils.setTextAppearance(
                labelView, R.style.PaymentsUiSectionDescriptiveText);
    } else if (mRowType == OPTION_ROW_TYPE_WARNING) {
        // Warnings use three columns.
        columnSpan = 3;
        ApiCompatibilityUtils.setTextAppearance(
                labelView, R.style.PaymentsUiSectionWarningText);
    }

    // The label spans two columns if no option or edit icon, or spans three columns if
    // no option and edit icons. Setting the view width to 0 forces it to stretch.
    GridLayout.LayoutParams labelParams = new GridLayout.LayoutParams(
            GridLayout.spec(rowIndex, 1, GridLayout.CENTER),
            GridLayout.spec(columnStart, columnSpan, GridLayout.FILL));
    labelParams.topMargin = mVerticalMargin;
    labelParams.width = 0;
    if (optionIconExists) {
        // Margin at the end of the label instead of the start of the option icon to
        // allow option icon in the the next row align with the end of label (include
        // end margin) when edit icon exits in that row, like below:
        // ---Label---------------------[label margin]|---option icon---|
        // ---Label---[label margin]|---option icon---|----edit icon----|
        ApiCompatibilityUtils.setMarginEnd(labelParams, mLargeSpacing);
    }
    parent.addView(labelView, labelParams);

    labelView.setOnClickListener(OptionSection.this);
    return labelView;
}
 
Example 12
private TextView createLabel(GridLayout parent, int rowIndex, boolean optionIconExists,
        boolean editIconExists, boolean isEnabled) {
    Context context = parent.getContext();
    Resources resources = context.getResources();

    // By default, the label appears to the right of the "button" in the second column.
    // + If there is no button, no option and edit icon, the label spans the whole row.
    // + If there is no option and edit icon, the label spans three columns.
    // + If there is no edit icon or option icon, the label spans two columns.
    // + Otherwise, the label occupies only its own column.
    int columnStart = 1;
    int columnSpan = 1;
    if (!optionIconExists) columnSpan++;
    if (!editIconExists) columnSpan++;

    TextView labelView = new TextView(context);
    if (mRowType == OPTION_ROW_TYPE_OPTION) {
        // Show the string representing the PaymentOption.
        ApiCompatibilityUtils.setTextAppearance(labelView, isEnabled
                ? R.style.PaymentsUiSectionDefaultText
                : R.style.PaymentsUiSectionDisabledText);
        labelView.setText(convertOptionToString(mOption,
                mDelegate.isBoldLabelNeeded(OptionSection.this),
                false /* singleLine */));
        labelView.setEnabled(isEnabled);
    } else if (mRowType == OPTION_ROW_TYPE_ADD) {
        // Shows string saying that the user can add a new option, e.g. credit card no.
        String typeface = resources.getString(R.string.roboto_medium_typeface);
        int textStyle = resources.getInteger(R.integer.roboto_medium_textstyle);
        int buttonHeight = resources.getDimensionPixelSize(
                R.dimen.payments_section_add_button_height);

        ApiCompatibilityUtils.setTextAppearance(
                labelView, R.style.PaymentsUiSectionAddButtonLabel);
        labelView.setMinimumHeight(buttonHeight);
        labelView.setGravity(Gravity.CENTER_VERTICAL);
        labelView.setTypeface(Typeface.create(typeface, textStyle));
    } else if (mRowType == OPTION_ROW_TYPE_DESCRIPTION) {
        // The description spans all the columns.
        columnStart = 0;
        columnSpan = 4;

        ApiCompatibilityUtils.setTextAppearance(
                labelView, R.style.PaymentsUiSectionDescriptiveText);
    } else if (mRowType == OPTION_ROW_TYPE_WARNING) {
        // Warnings use three columns.
        columnSpan = 3;
        ApiCompatibilityUtils.setTextAppearance(
                labelView, R.style.PaymentsUiSectionWarningText);
    }

    // The label spans two columns if no option or edit icon, or spans three columns if
    // no option and edit icons. Setting the view width to 0 forces it to stretch.
    GridLayout.LayoutParams labelParams =
            new GridLayout.LayoutParams(GridLayout.spec(rowIndex, 1, GridLayout.CENTER),
                    GridLayout.spec(columnStart, columnSpan, GridLayout.FILL, 1f));
    labelParams.topMargin = mVerticalMargin;
    labelParams.width = 0;
    if (optionIconExists) {
        // Margin at the end of the label instead of the start of the option icon to
        // allow option icon in the the next row align with the end of label (include
        // end margin) when edit icon exits in that row, like below:
        // ---Label---------------------[label margin]|---option icon---|
        // ---Label---[label margin]|---option icon---|----edit icon----|
        ApiCompatibilityUtils.setMarginEnd(labelParams, mLargeSpacing);
    }
    parent.addView(labelView, labelParams);

    labelView.setOnClickListener(OptionSection.this);
    return labelView;
}
 
Example 13
Source Project: ProjectX   File: SubLayout.java    License: Apache License 2.0 4 votes vote down vote up
SubLayout(Context context) {
    super(context);
    setWillNotDraw(false);
    final Resources resources = context.getResources();
    int size = resources.getDimensionPixelOffset(R.dimen.floatingActionModeItemSize);
    int textColor = resources.getColor(R.color.floatingActionModeSubTitleTextColor);
    float textSize = resources.getDimension(R.dimen.floatingActionModeSubTitleTextSize);
    @SuppressLint("CustomViewStyleable") final TypedArray custom =
            context.obtainStyledAttributes(R.styleable.FloatingActionMode);
    size = custom.getDimensionPixelOffset(
            R.styleable.FloatingActionMode_floatingActionModeItemSize, size);
    final int textAppearance = custom.getResourceId(
            R.styleable.FloatingActionMode_floatingActionModeSubTitleTextAppearance, 0);
    textColor = custom.getColor(
            R.styleable.FloatingActionMode_floatingActionModeSubTitleTextColor, textColor);
    textSize = custom.getDimension(
            R.styleable.FloatingActionMode_floatingActionModeSubTitleTextSize, textSize);
    custom.recycle();
    setOrientation(VERTICAL);
    mTitle = new TextView(context);
    if (textAppearance != 0)
        mTitle.setTextAppearance(context, textAppearance);
    else {
        final TypedArray a = context.obtainStyledAttributes(
                new int[]{android.R.attr.textAppearanceListItemSmall});
        mTitle.setTextAppearance(context, a.getResourceId(0, 0));
        a.recycle();
    }
    mTitle.setBackgroundDrawable(null);
    mTitle.setEllipsize(TextUtils.TruncateAt.END);
    mTitle.setFocusable(false);
    mTitle.setFocusableInTouchMode(false);
    mTitle.setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL));
    mTitle.setGravity(Gravity.CENTER);
    mTitle.setSingleLine();
    mTitle.setTextColor(textColor);
    mTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    mTitle.setMinimumHeight(size);
    mTitle.setPadding(size, 0, size, 0);
    if (Build.VERSION.SDK_INT >= 16)
        mTitle.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
    mTitle.setLayoutParams(new LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    mList = new SubListView(context);
    mListMaxHeight = mList.getMaxHeight();
    mParams = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    mParams.weight = 1;
    mCornerCrop.setFillType(Path.FillType.EVEN_ODD);
    mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
    mCropPath.setFillType(Path.FillType.EVEN_ODD);
    mList.setOnItemClickListener(this);
}