操作栏中 textview 的选取框文本在 setText 之后不选取任何人

marquee text of textview in actionbar not marquee anyone after setText

我有一个 ActionBar 和一个 TextView

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        >

        <TextView
            android:id="@+id/title_text"
            android:text="This will run the marquee animation forever"
            android:textSize="@dimen/abc_text_size_title_material_toolbar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ellipsize="marquee"
            android:marqueeRepeatLimit="marquee_forever"
            android:scrollHorizontally="true"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:singleLine="true"
            android:paddingTop="20px"/>

</RelativeLayout>

在我的 Activity:

    ActionBar mActionBar = getActionBar();
    mActionBar.setDisplayShowHomeEnabled(false);
    mActionBar.setDisplayShowTitleEnabled(false);
    LayoutInflater mInflater = LayoutInflater.from(this);

    View mCustomView = mInflater.inflate(R.layout.custom_actionbar, null);
    TextView mTitleTextView = (TextView) mCustomView.findViewById(R.id.title_text);

//下一行之前的字幕文本工作

    mTitleTextView.setText("My Own Title");

//上面一行之后的选取框文本不起作用

    mActionBar.setCustomView(mCustomView);
    mActionBar.setDisplayShowCustomEnabled(true);

有人知道问题出在哪里吗?

你试过 mTitleTextView.setSelected(true); after setText("Your text"); ?

设置好文字后,添加以下内容

    mTitleTextView.setSelected(true);
    mTitleTextView.setEllipsize(TruncateAt.MARQUEE);