【问题标题】:How to have a selectable background together with a certain color background?如何有一个可选择的背景和某种颜色的背景?
【发布时间】:2017-03-26 09:56:12
【问题描述】:

我知道你会得到一个可选的(高亮/波纹)背景,使用这个:

android:background="?attr/selectableItemBackground"

但是,如果我想要某种颜色的背景以及波纹/高光,该怎么办?

(我希望有几行代码不涉及创建单独的可绘制对象,这非常不雅)

【问题讨论】:

    标签: android colors selection background-color


    【解决方案1】:

    试试这个

    <?xml version="1.0" encoding="utf-8"?>
    <ripple xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:color="#f816a463"
        tools:targetApi="lollipop">
        <item android:id="@android:id/mask">
            <shape android:shape="rectangle">
                <solid android:color="#f816a463" />  <--your custom color-->
            </shape>
        </item>
    </ripple>
    

    然后

    android:background="@drawable/ripple_effect"
    

    在您的按钮中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-13
      • 2011-07-22
      • 2012-05-23
      相关资源
      最近更新 更多