簡體   English   中英

設置 android:foreground 查看無邊框

[英]Set android:foreground View borderless

如何在Android開發中設置android:foreground drawable of a button無邊框? 就像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/得到了這個答案

並且您的問題可能與如何使用 style.xml 文件(以及所有其他樣式)中的樣式創建無邊框按鈕的問題重復

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM