我在我的小部件的两个不同 TextView 中使用选取框。但是当我尝试使用“android:focusable="true"",android:focusableInTouchMode="的不同组合时,它仅适用于第一个或第二个 TextView真”和机器人:duplicateParentState =“真”。我希望两个 TextView 都在移动。 我在下面给出了我正在使用的代码。
<TextView
android:id="@+id/place"
android:layout_width="94dip"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:lines="1"
android:textColor="@color/white"
android:focusable="true"
android:focusableInTouchMode="true"
>
<requestFocus
android:duplicateParentState="true"
/>
</TextView>
<TextView
android:id="@+id/weather_report"
android:layout_width="110dip"
android:layout_height="wrap_content"
android:layout_below="@+id/place"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:lines="1"
android:textColor="@color/grey"
android:focusable="true"
android:focusableInTouchMode="true"
>
<requestFocus
android:duplicateParentState="true"
/>
</TextView>
谁能知道解决办法?
最佳答案
我很确定你不能做你想做的事。只有焦点 View 才能“选框”,并且由于您不能拥有两个焦点 View ,因此不可能开箱即用。但是,您可以 look at the startMarquee()
method在 TextView
中并扩展一个始终选取框的自定义 TextView。
关于android - 在多个 TextView 中使用时选取框不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9568023/