gpt4 book ai didi

android - Button 的 "state_focused"状态是什么?

转载 作者:IT老高 更新时间:2023-10-28 22:00:24 26 4
gpt4 key购买 nike

我希望按钮背景在单击按钮后保持某种颜色,并在按下其他按钮时再次更改颜色。我认为这是“state_focused”状态。

但我的按钮似乎只有两种状态是按下或未按下。

我是否正确理解 state_focused 状态,还是我的 StateListDrawable(见下文)错误?

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:state_focused="true" android:state_pressed="false"><shape>
<solid android:color="#00ff00" />
</shape></item>
<item android:state_pressed="true"><shape>
<solid android:color="#ff0000" />
</shape></item>
<item><shape>
<solid android:color="#0000ff" />
</shape></item>

</selector>

最佳答案

state_focused 是当按钮使用 dpad 或轨迹球聚焦时。使用触摸时, View 通常不会显示焦点状态。

关于android - Button 的 "state_focused"状态是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8852420/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com