android - How to make shape's child TextView white when state_pressed="true" -
android - How to make shape's child TextView white when state_pressed="true" -
this shape backround of linearlayout, how can create textviews within linearlayout alter text color white during statepressed =true of parent selector? see previous question see more of code: shape not show
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#ffffff" /> <stroke android:width="1dp" android:color="#aa000000" /> <corners android:topleftradius="10dp" android:toprightradius="10dp" /> <gradient android:startcolor="#6633cc" android:endcolor="#00ccff" android:angle="270" /> </shape>
pressed state propagated kid views of layout. can declare state list of colors how declare state list of drawables. if set state list color on text within parent becomes pressed, pressed state apply text color well.
edit: quoted info partially wrong , edited in else:
use: android:duplicateparentstate="true" textview, use: android:color="@color/mynewcolor"
this xml color file placed in res/color directory of project.
here's illustration aosp, used default text: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/res/res/color/primary_text_dark.xml;h=f0812edbadcbcf6cd1a887b374ce7b6209e7d1b8;hb=head
edit: edited reply wrong information. pressed state propagated regardless of android:duplicateparentstate setting.
view.java, setpressed method invokes dispatchsetpressed: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/view/view.java;h=232dd6a8f63f4a3405053211d37e29c8a418ccc1;hb=head#l3361
viewgroup.java, overridden dispatchsetpressed method sets kid views pressed: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/view/viewgroup.java;h=2b71b4a492e04d13cf46d5a1eee91f8a43f89112;hb=head#l1710
android android-layout
Comments
Post a Comment