什么是" state_focused"状态的按钮? [英] What is the "state_focused" state for a Button?

查看:237
本文介绍了什么是" state_focused"状态的按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一个按钮背景保持一定的颜色按钮被点击后,再次改变颜色时,其他一些按钮pssed $ P $。我认为这是state_focused状态。

但只有两种状态我似乎对我的按钮是pressed与否pressed。

我理解的正确的state_focused状态,或者是我的StateListDrawable(见下文),错了吗?

 < XML版本=1.0编码=UTF-8&GT?;
<选择的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>

    <项目安卓state_focused =真正的机器人:STATE_ pressed =假><形状>
            [固体机器人:颜色=#00FF00/>
        < /形状>< /项目>
    <项目的android:STATE_ pressed =真正的><形状>
            [固体机器人:颜色=#FF0000/>
        < /形状>< /项目>
    <项目><形状>
            [固体机器人:颜色=#0000FF/>
        < /形状>< /项目>

< /选择器>
 

解决方案

state_focused 是每当按钮的重点是使用DPAD或轨迹球。采用触摸意见时,通常不会显示出聚焦状态。

I would like a Button background to remain a certain color after the button is clicked, and change colors again when some other button is pressed. I thought this was the "state_focused" state.

But the only two states I seem to have for my Button is pressed or not pressed.

Do I understand the state_focused state correctly, or is my StateListDrawable (see below) wrong?

<?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 is whenever the button is focused on using a dpad or the trackball. Views don't generally show a focused state when using touch.

这篇关于什么是&QUOT; state_focused&QUOT;状态的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆