android - 在 android XML 上结合多个背景?

标签 android xml drawable

我可以结合我自己的 android drawable 和 ?android:selectableItemBackground... 吗? 我搜索了很多,但我找不到正确的答案...... 例如,假设我有一个简单的按钮,我想要这个:

<Button
    android:id="@+id/bTest"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="?android:selectableItemBackground" | @drawable/myDrawable/>

有什么想法吗?

最佳答案

如何使用FrameLayout

<FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/myDrawable">
    <Button
        android:id="@+id/bTest"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="?android:selectableItemBackground"/>
</FrameLayout>

或者使用ImageButton

<ImageButton
    android:id="@+id/bTest"
    android:src="@drawable/myDrawable"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="?android:selectableItemBackground"/>

关于android - 在 android XML 上结合多个背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38635056/

相关文章:

android - 反转drawable的颜色

java - org.json.JSONObject 构造函数不接受看似有效的 JSON 字符串

java - 如何让我的 Android 应用程序生成随机数?

java - 当用户从最近的任务列表中关闭应用程序时,如何保持作业服务运行

Android 可绘制对象(图标)列表

android - 我可以在 @Composable 之外使用 Jetpack 撰写图标吗?

android - 用 Admob 广告替换 Google Adsense 广告

c# - XmlTextWriter 错误地写入控制字符

android - 包含来自另一个包的 xml 布局

xml - 带有命名空间的 T-Sql xml 查询