I specified a selector drawable for the background of a layout as below, so when user clicks on the layout, the layout will have a different background. But, I didn't specify color selector for the TextViews in the layout, because there are many TextViews with different colors and I am too lazy to define color selector for them. So the text c开发者_如何学JAVAolor keeps the same when the layout is clicked. My questions is, is there an automatic way to specify that the text color is highlighted/changed when the layout is clicked, so I don't have to define color selector for each of the TextViews in a layout? Thanks.
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/background_selector"
>
<TextView android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/my_green"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
/>
<TextView android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/my_blue"
android:layout_alignParentLeft="true"
android:layout_below="@id/text1"
/>
</RelativeLayout>
You should be able to define a theme as an XML file and set it with Activity.setTheme()
- that will globally apply to everything.
精彩评论