当前位置: 首页>>代码示例>>Java>>正文


Java ApiCompatibilityUtils.setTextAppearance方法代码示例

本文整理汇总了Java中org.chromium.base.ApiCompatibilityUtils.setTextAppearance方法的典型用法代码示例。如果您正苦于以下问题:Java ApiCompatibilityUtils.setTextAppearance方法的具体用法?Java ApiCompatibilityUtils.setTextAppearance怎么用?Java ApiCompatibilityUtils.setTextAppearance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.chromium.base.ApiCompatibilityUtils的用法示例。


在下文中一共展示了ApiCompatibilityUtils.setTextAppearance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createMainSectionContent

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
@Override
protected void createMainSectionContent(LinearLayout mainSectionLayout) {
    Context context = mainSectionLayout.getContext();

    mExtraTextViews = new TextView[3];
    for (int i = 0; i < mExtraTextViews.length; i++) {
        mExtraTextViews[i] = new TextView(context);
        ApiCompatibilityUtils.setTextAppearance(
                mExtraTextViews[i], R.style.PaymentsUiSectionDefaultText);
        mainSectionLayout.addView(
                mExtraTextViews[i], new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                                            LayoutParams.WRAP_CONTENT));
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:15,代码来源:PaymentRequestSection.java

示例2: getDropDownView

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
    View view;

    // Add a "+" icon and a blue tint to the last element.
    if (position == getCount() - 1) {
        view = super.getDropDownView(position, convertView, parent);
        TextView tv = (TextView) view;
        Resources resources = getContext().getResources();

        // Create the "+" icon, put it left of the text and add appropriate padding.
        tv.setCompoundDrawablesWithIntrinsicBounds(
                TintedDrawable.constructTintedDrawable(
                    resources, R.drawable.plus, R.color.light_active_color),
                null, null, null);
        tv.setCompoundDrawablePadding(
                resources.getDimensionPixelSize(R.dimen.payments_section_large_spacing));

        // Set the correct appearance, face and style for the text.
        ApiCompatibilityUtils.setTextAppearance(tv, R.style.PaymentsUiSectionAddButtonLabel);
        tv.setTypeface(Typeface.create(
                resources.getString(R.string.roboto_medium_typeface),
                R.integer.roboto_medium_textstyle));
    } else {
        // Don't use the recycled convertView, as it may have the style of the last element.
        view = super.getDropDownView(position, null, parent);
    }

    return view;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:31,代码来源:BillingAddressAdapter.java

示例3: prepareMainSection

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
/**
 * Creates the main section.  Subclasses must call super#createMainSection() immediately to
 * guarantee that Views are added in the correct order.
 *
 * @param sectionName Title to display for the section.
 */
private LinearLayout prepareMainSection(String sectionName) {
    // The main section is a vertical linear layout that subclasses can append to.
    LinearLayout mainSectionLayout = new LinearLayout(getContext());
    mainSectionLayout.setOrientation(VERTICAL);
    LinearLayout.LayoutParams mainParams = new LayoutParams(0, LayoutParams.WRAP_CONTENT);
    mainParams.weight = 1;
    addView(mainSectionLayout, mainParams);

    // The title is always displayed for the row at the top of the main section.
    mTitleView = new TextView(getContext());
    mTitleView.setText(sectionName);
    ApiCompatibilityUtils.setTextAppearance(
            mTitleView, R.style.PaymentsUiSectionHeader);
    mainSectionLayout.addView(
            mTitleView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    // Create the two TextViews for showing the summary text.
    mSummaryLeftTextView = new TextView(getContext());
    mSummaryLeftTextView.setId(R.id.payments_left_summary_label);
    ApiCompatibilityUtils.setTextAppearance(
            mSummaryLeftTextView, R.style.PaymentsUiSectionDefaultText);

    mSummaryRightTextView = new TextView(getContext());
    ApiCompatibilityUtils.setTextAppearance(
            mSummaryRightTextView, R.style.PaymentsUiSectionDefaultText);
    ApiCompatibilityUtils.setTextAlignment(mSummaryRightTextView, TEXT_ALIGNMENT_TEXT_END);

    // The main TextView sucks up all the available space.
    LinearLayout.LayoutParams leftLayoutParams = new LinearLayout.LayoutParams(
            0, LayoutParams.WRAP_CONTENT);
    leftLayoutParams.weight = 1;

    LinearLayout.LayoutParams rightLayoutParams = new LinearLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    ApiCompatibilityUtils.setMarginStart(
            rightLayoutParams,
            getContext().getResources().getDimensionPixelSize(
                    R.dimen.payments_section_small_spacing));

    // The summary section displays up to two TextViews side by side.
    mSummaryLayout = new LinearLayout(getContext());
    mSummaryLayout.addView(mSummaryLeftTextView, leftLayoutParams);
    mSummaryLayout.addView(mSummaryRightTextView, rightLayoutParams);
    mainSectionLayout.addView(mSummaryLayout, new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    setSummaryText(null, null);

    createMainSectionContent(mainSectionLayout);
    return mainSectionLayout;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:57,代码来源:PaymentRequestSection.java

示例4: update

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:62,代码来源:PaymentRequestSection.java

示例5: createLabel

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
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;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:71,代码来源:PaymentRequestSection.java

示例6: showCertificateChain

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
private void showCertificateChain(byte[][] derData) {
    for (int i = 0; i < derData.length; i++) {
        addCertificate(derData[i]);
    }
    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(mContext,
            android.R.layout.simple_spinner_item,
            mTitles) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            TextView view = (TextView) super.getView(position, convertView, parent);
            // Add extra padding on the end side to avoid overlapping the dropdown arrow.
            ApiCompatibilityUtils.setPaddingRelative(view, mPadding, mPadding, mPadding * 2,
                    mPadding);
            return view;
        }
    };
    arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    LinearLayout dialogContainer = new LinearLayout(mContext);
    dialogContainer.setOrientation(LinearLayout.VERTICAL);

    TextView title = new TextView(mContext);
    title.setText(R.string.certtitle);
    ApiCompatibilityUtils.setTextAlignment(title, View.TEXT_ALIGNMENT_VIEW_START);
    ApiCompatibilityUtils.setTextAppearance(title, android.R.style.TextAppearance_Large);
    title.setTypeface(title.getTypeface(), Typeface.BOLD);
    title.setPadding(mPadding, mPadding, mPadding, mPadding / 2);
    dialogContainer.addView(title);

    Spinner spinner = new Spinner(mContext);
    ApiCompatibilityUtils.setTextAlignment(spinner, View.TEXT_ALIGNMENT_VIEW_START);
    spinner.setAdapter(arrayAdapter);
    spinner.setOnItemSelectedListener(this);
    spinner.setDropDownWidth(ViewGroup.LayoutParams.MATCH_PARENT);
    // Remove padding so that dropdown has same width as the spinner.
    spinner.setPadding(0, 0, 0, 0);
    dialogContainer.addView(spinner);

    LinearLayout certContainer = new LinearLayout(mContext);
    certContainer.setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < mViews.size(); ++i) {
        LinearLayout certificateView = mViews.get(i);
        if (i != 0) {
            certificateView.setVisibility(LinearLayout.GONE);
        }
        certContainer.addView(certificateView);
    }
    ScrollView scrollView = new ScrollView(mContext);
    scrollView.addView(certContainer);
    dialogContainer.addView(scrollView);

    showDialogForView(dialogContainer);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:54,代码来源:CertificateViewer.java

示例7: FloatLabelLayout

import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
public FloatLabelLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setOrientation(VERTICAL);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatLabelLayout);

    int leftPadding = a.getDimensionPixelSize(
            R.styleable.FloatLabelLayout_floatLabelPaddingLeft,
            dipsToPix(DEFAULT_LABEL_PADDING_LEFT));
    int topPadding = a.getDimensionPixelSize(
            R.styleable.FloatLabelLayout_floatLabelPaddingTop,
            dipsToPix(DEFAULT_LABEL_PADDING_TOP));
    int rightPadding = a.getDimensionPixelSize(
            R.styleable.FloatLabelLayout_floatLabelPaddingRight,
            dipsToPix(DEFAULT_LABEL_PADDING_RIGHT));
    int bottomPadding = a.getDimensionPixelSize(
            R.styleable.FloatLabelLayout_floatLabelPaddingBottom,
            dipsToPix(DEFAULT_LABEL_PADDING_BOTTOM));
    mHint = a.getText(R.styleable.FloatLabelLayout_floatLabelHint);

    mLabel = new TextView(context);
    mLabel.setPadding(leftPadding, topPadding, rightPadding, bottomPadding);
    mLabel.setVisibility(INVISIBLE);
    mLabel.setText(mHint);
    mLabel.setFocusable(true);
    ViewCompat.setPivotX(mLabel, 0f);
    ViewCompat.setPivotY(mLabel, 0f);

    ApiCompatibilityUtils.setTextAppearance(mLabel,
            a.getResourceId(R.styleable.FloatLabelLayout_floatLabelTextAppearance,
                    android.R.style.TextAppearance_Small));
    a.recycle();

    addView(mLabel, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    mInterpolator = AnimationUtils.loadInterpolator(context,
            Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
                ? android.R.interpolator.fast_out_slow_in
                : android.R.anim.decelerate_interpolator);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:42,代码来源:FloatLabelLayout.java


注:本文中的org.chromium.base.ApiCompatibilityUtils.setTextAppearance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。