java - 设置安卓:foreground View borderless

标签 java android android-layout

Android开发中如何设置按钮的android:foregrounddrawable为无边框?就像 android:background="?android:attr/selectableItemBackgroundBorderless" 的情况一样。

最佳答案

你可以使用多种方法

1. android:background="@android:color/transparent"

2. android:background="?android:attr/selectableItemBackground"

3. style="?android:attr/borderlessButtonStyle"

4. android:background="@drawable/btn_borderless" 

在第四种方法中,您将需要在可绘制文件夹中添加一个 xml 文件 btn_borderless,例如

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

我从 https://inducesmile.com/android-programming/how-to-create-borderless-button-in-android/ 得到了这个答案

您的问题可能与 How to create borderless button using style from style.xml file (along with all other styles) 重复

关于java - 设置安卓:foreground View borderless,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61984979/

相关文章:

Android:如何使用 shell 命令或 Intent 运行 google music 的 "Shuffle all"?

java - OnKeyListener.onKey 未被调用

Java - 将 String[] 数组的所有值转换/复制到 ArrayList<BigInteger>

Android 抑制特定属性的 UnusedAttribute 警告

java - 如果无法通过 Java 中的 DNS 解析,如何获取本地主机名?

java - 无法使用 asynctask 获取自定义列表适配器来填充 ListView

android - 使用自定义进度条?

带有添加按钮的 Android ListPreference

java - Jframe 不会在 "X"上关闭

java - Oozie-将jar文件复制到Cloudera上的lib文件夹时被截断