android - 在多个 TextView 中使用时选取框不起作用

标签 android android-layout android-widget

我在我的小部件的两个不同 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() methodTextView 中并扩展一个始终选取框的自定义 TextView。

关于android - 在多个 TextView 中使用时选取框不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9568023/

相关文章:

android - 如何自定义Cyanogenmod Source?

Android EditText inputType ="none"不起作用,变为 "textMultiLine"

java - Android Java 对话框中触摸事件的颜色触摸区域

java - 更新 ArrayAdapter 中的数据

android - 我怎样才能像这样设置 'EditText'的样式呢?

java - 设备未准备好 gradle 同步失败

android - 我的 FragmentActivity 中的 ClassNotFoundException mopub

java - 使 ConstraintLayout 组件在简单的 UI 中填充整个显示

android - StylePlayerView Controller xml 覆盖播放和暂停按钮不起作用

android - 即使手机处于 sleep 状态,也要保持服务运行?