TextView color change on focus/press

好久不见. 提交于 2019-11-30 02:56:23

问题


I have a some ui widgets including textview inside RelativeLayout which is clickable. My problem is textview text color does not change when relativelayout gets focus although I have set textview color property correctly.

Is there any easy way to cascade focus to childview inside relative layout, same as listview items.

    <RelativeLayout
    android:id="@+id/top_layout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
            android:background="@drawable/selector_white_blue"
    >
    <TextView
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentLeft="true"
        android:textSize="@dimen/text_size_med"
        android:textColor="@color/black_text_white_focused"
        android:textStyle="bold"
        android:text="Movie Name"
        />
</RelativeLayout>   

回答1:


Specify android:duplicateParentState='true' on your TextView.




回答2:


Programmatically by textView.setDuplicateParentStateEnabled(true);

for your

TextView textView= new TextView(this);



来源:https://stackoverflow.com/questions/6360297/textview-color-change-on-focus-press

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!