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

The following examples show how to use android.widget.TextView#setMarqueeRepeatLimit() . 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: TitleBar   File: ViewCore.java    License: Apache License 2.0 6 votes vote down vote up
static TextView newTitleView(Context context) {
    TextView titleView = new TextView(context);
    titleView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1));
    titleView.setGravity(Gravity.CENTER);
    titleView.setFocusable(true);
    titleView.setSingleLine();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.BASE_1_1) {
        // 给标题设置跑马灯效果(仅在标题过长的时候才会显示)
        titleView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
        // 设置跑马灯的循环次数
        titleView.setMarqueeRepeatLimit(-1);
        // 设置跑马灯之后需要设置选中才能有效果
        titleView.setSelected(true);
    } else {
        titleView.setEllipsize(TextUtils.TruncateAt.END);
    }
    return titleView;
}
 
Example 2
Source Project: SAI   File: Coolbar.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void init() {
    mTitle = new TextView(getContext());
    mTitle.setText(mTitleText);
    mTitle.setBackgroundColor(Color.TRANSPARENT);
    mTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, DEFAULT_TITLE_TEXT_SIZE_SP);
    mTitle.setTextColor(mTitleColor);
    mTitle.setGravity(Gravity.CENTER);
    mTitle.setSingleLine();
    mTitle.setEllipsize(TextUtils.TruncateAt.MARQUEE);
    mTitle.setMarqueeRepeatLimit(-1);
    mTitle.setSelected(true);
    addView(mTitle);

    if (getBackground() == null)
        setBackgroundColor(getThemeColor(R.attr.colorPrimary, Color.WHITE));
}
 
Example 3
Source Project: badgedtablayout   File: BadgedTabLayout.java    License: MIT License 5 votes vote down vote up
/**
 * @param tab  for which custom title is created
 * @param view custom view, manually inflated from badged_tab.xml
 */
private void makeCustomTitle(Tab tab, View view) {
    TextView title = view.findViewById(R.id.textview_tab_title);

    title.setTextColor(getTabTextColors());

    if (tabTextSize != 0)
        title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);

    if (tabTruncateAt != null)
        title.setEllipsize(tabTruncateAt);

    if (tabFont != null)
        title.setTypeface(tabFont);

    if (isSpanText) {
        title.setSingleLine(false);
        title.setMarqueeRepeatLimit(-1);
        title.setEllipsize(TextUtils.TruncateAt.MIDDLE);
    }

    if (maxWidthText != -1)
        title.setMaxWidth(maxWidthText);

    if (!TextUtils.isEmpty(tab.getText()))
        title.setText(tab.getText());
    else
        title.setVisibility(GONE);
}
 
Example 4
Source Project: VCL-Android   File: Util.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Set the alignment mode of the specified TextView with the desired align
 * mode from preferences.
 *
 * See @array/audio_title_alignment_values
 *
 * @param alignMode Align mode as read from preferences
 * @param t Reference to the textview
 */
public static void setAlignModeByPref(int alignMode, TextView t) {
    if(alignMode == 1)
        t.setEllipsize(TruncateAt.END);
    else if(alignMode == 2)
        t.setEllipsize(TruncateAt.START);
    else if(alignMode == 3) {
        t.setEllipsize(TruncateAt.MARQUEE);
        t.setMarqueeRepeatLimit(-1);
        t.setSelected(true);
    }
}
 
Example 5
Source Project: XBanner   File: XBanner.java    License: Apache License 2.0 4 votes vote down vote up
private void initView() {

        /*设置指示器背景容器*/
        RelativeLayout pointContainerRl = new RelativeLayout(getContext());
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            pointContainerRl.setBackground(mPointContainerBackgroundDrawable);
        } else {
            pointContainerRl.setBackgroundDrawable(mPointContainerBackgroundDrawable);
        }

        /*设置内边距*/
        pointContainerRl.setPadding(mPointContainerLeftRightPadding, mPointTopBottomPading, mPointContainerLeftRightPadding, mPointTopBottomPading);

        /*设定指示器容器布局及位置*/
        mPointContainerLp = new LayoutParams(RMP, RWC);
        mPointContainerLp.addRule(mPointContainerPosition);
        if (mIsClipChildrenMode) {
            mPointContainerLp.setMargins(mClipChildrenLeftRightMargin, 0, mClipChildrenLeftRightMargin, mClipChildrenTopBottomMargin);
        }
        addView(pointContainerRl, mPointContainerLp);
        mPointRealContainerLp = new LayoutParams(RWC, RWC);
        /*设置指示器容器*/
        if (mIsNumberIndicator) {
            mNumberIndicatorTv = new TextView(getContext());
            mNumberIndicatorTv.setId(R.id.xbanner_pointId);
            mNumberIndicatorTv.setGravity(Gravity.CENTER);
            mNumberIndicatorTv.setSingleLine(true);
            mNumberIndicatorTv.setEllipsize(TextUtils.TruncateAt.END);
            mNumberIndicatorTv.setTextColor(mTipTextColor);
            mNumberIndicatorTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTipTextSize);
            mNumberIndicatorTv.setVisibility(View.INVISIBLE);
            if (mNumberIndicatorBackground != null) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    mNumberIndicatorTv.setBackground(mNumberIndicatorBackground);
                } else {
                    mNumberIndicatorTv.setBackgroundDrawable(mNumberIndicatorBackground);
                }
            }
            pointContainerRl.addView(mNumberIndicatorTv, mPointRealContainerLp);
        } else {
            mPointRealContainerLl = new LinearLayout(getContext());
            mPointRealContainerLl.setOrientation(LinearLayout.HORIZONTAL);
            mPointRealContainerLl.setId(R.id.xbanner_pointId);
            pointContainerRl.addView(mPointRealContainerLl, mPointRealContainerLp);
        }

        /*设置指示器是否可见*/
        if (mPointRealContainerLl != null) {
            if (mPointsIsVisible) {
                mPointRealContainerLl.setVisibility(View.VISIBLE);
            } else {
                mPointRealContainerLl.setVisibility(View.GONE);
            }
        }

        /*设置提示语*/
        LayoutParams pointLp = new LayoutParams(RMP, RWC);
        pointLp.addRule(CENTER_VERTICAL);

        if (mIsShowTips) {
            mTipTv = new TextView(getContext());
            mTipTv.setGravity(Gravity.CENTER_VERTICAL);
            mTipTv.setSingleLine(true);
            if (mIsTipsMarquee) {
                mTipTv.setEllipsize(TextUtils.TruncateAt.MARQUEE);
                mTipTv.setMarqueeRepeatLimit(3);
                mTipTv.setSelected(true);
            } else {
                mTipTv.setEllipsize(TextUtils.TruncateAt.END);
            }
            mTipTv.setTextColor(mTipTextColor);
            mTipTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTipTextSize);
            pointContainerRl.addView(mTipTv, pointLp);
        }

        /*设置指示器布局位置*/
        if (CENTER == mPointPosition) {
            mPointRealContainerLp.addRule(RelativeLayout.CENTER_HORIZONTAL);
            pointLp.addRule(RelativeLayout.LEFT_OF, R.id.xbanner_pointId);
        } else if (LEFT == mPointPosition) {
            mPointRealContainerLp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            if (mTipTv != null) {
                mTipTv.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
            }
            pointLp.addRule(RelativeLayout.RIGHT_OF, R.id.xbanner_pointId);
        } else if (RIGHT == mPointPosition) {
            mPointRealContainerLp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            pointLp.addRule(RelativeLayout.LEFT_OF, R.id.xbanner_pointId);
        }
        setBannerPlaceholderDrawable();
    }