【问题标题】:How to change button background as a progress?如何将按钮背景更改为进度?
【发布时间】:2016-02-08 00:01:06
【问题描述】:

我正在尝试在按下按钮时将其背景更改为“正在加载”,但我不知道如何制作。

首先我尝试使用进度条,但是,我想要的是在按下按钮时逐步加载背景,或者在释放按钮时恢复背景。

提前感谢您的任何想法。

【问题讨论】:

    标签: android xml animation button view


    【解决方案1】:

    将按钮背景设置为选择器,比如这个

        <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:drawable="@drawable/loading" android:state_pressed="true" />
        <!-- pressed -->
        <item android:drawable="@drawable/normal" android:state_focused="true" />
        <!-- focused -->
        <item android:drawable="@drawable/normal" />
        <!-- default -->
    </selector>
    

    这应该会在您按下并释放按钮时更改按钮背景。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多