本文介绍了如何使图形的孩子的TextView白当STATE_ pressed ="真"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这形状是的LinearLayout的底色,我怎么能做出的LinearLayout内的任何TextViews状态$ P $过程中更改它们的文本颜色为白色pssed =家长选择的是真的吗?另见我的previous问题多看看code的:形状不显示

 <形状
            的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
            [固体
                机器人:颜色=#FFFFFF/>
            <中风
                机器人:宽=1DP
                机器人:颜色=#AA000000/>
            <角落
                机器人:topLeftRadius =10dp
                机器人:topRightRadius =10dp/>
            <梯度
                机器人:startColor =#6633cc
                机器人:ENDCOLOR =#00CCFF
                机器人:角=270/>
        < /形状>


pressed状态传播到布局的所有子视图。你可以声明的颜色状态列表类似你如何声明可绘制的状态列表。如果设置父内文本的状态列表颜色变成pressed中,pressed国家将适用于文本颜色为好。

编辑:报价信息是部分不正确,被别人编辑的:

This XML color file is placed in the res/color directory of a project.

Here's an example from AOSP, used for 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: You edited my answer with incorrect information. Pressed state is propagated regardless of the android:duplicateParentState setting.

View.java, the 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, the overridden dispatchSetPressed method sets all child 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

这篇关于如何使图形的孩子的TextView白当STATE_ pressed ="真"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 15:18