Yog*_*ade 5 android marquee textview android-layout
Marquee不适合我的TextView请检查下面的代码
XML代码为 TextView
<TextView
android:id="@+id/mtextcash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="30dp"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:gravity="center"
android:marqueeRepeatLimit="marquee_forever"
android:maxLength="5"
android:scrollHorizontally="true"
android:scrollbars="horizontal"
android:singleLine="true"
android:text="Simple application that shows how to use marquee, with a long text"
android:textColor="@color/white"
android:textColorHint="@color/white"
android:textSize="25dp" />
Run Code Online (Sandbox Code Playgroud)
在活动OnCreate中
TextView inputAvailableCash = (TextView) findViewById(R.id.mtextcash);
inputAvailableCash.setSelected(true);
Run Code Online (Sandbox Code Playgroud)
提前致谢
由于文本很长,并且只有在单行编写文本时才能使用代码.要么添加
android:singleline="true"
Run Code Online (Sandbox Code Playgroud)
在xml中或将您的Java代码更改为.
TextView inputAvailableCash = (TextView) findViewById(R.id.mtextcash);
inputAvailableCash.setSelected(true);
inputAvailableCash.setSingleLine(true);
Run Code Online (Sandbox Code Playgroud)
这肯定会对你有用.
在xml文件中添加该属性
android:focusable="true"
android:focusableInTouchMode="true"
Run Code Online (Sandbox Code Playgroud)