android marquee textview 走马灯效果
网上查的全都不能用。还是自己试验出来的。。。
测试机版本:4.0.3
网上有文章说要加 addStatesFromChildren
实测:加不加都能正常滚动
android:focusable="true"
实测:必须在xml里添加。在程序中使用tv.setFocusable(true);不能滚动
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:addStatesFromChildren="true"
>
<TextView
android:id="@+id/tv"
android:layout_width="100px"
android:layout_height="wrap_content"
android:text="11adshfkalhafklajfhkadjfhakjfhdjkfhadfjkhasdfhasdfjkhasdjkfhsdakfhasdjkfhasdkfhsajkdfhsdfhsadfkjhsaf"
android:singleLine="true"
android:marqueeRepeatLimit="marquee_forever"
android:ellipsize="marquee"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
android:focusable="true"
/>
<Button
android:layout_width="100px"
android:layout_height="wrap_content"
android:text="sad"
/>
</LinearLayout>
下面加的那个Button时为了测试焦点问题添加的
点击Button对 滚动 无影响 (点击时Button获取焦点)