簡體   English   中英

Android 按鈕垂直填充?

[英]Android Button Vertical Padding?

這是我的代碼:

<com.google.android.material.button.MaterialButton
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:text="nice"
            android:paddingVertical="0dp"
            android:textColor="@color/light_grey"
            app:strokeWidth="2dp"
            app:strokeColor="@color/light_grey"
            app:cornerRadius="10dp"
            android:backgroundTint="@color/white"/>

這就是按鈕。

按鈕的圖像它有一個垂直空間,顯然不是填充,使按鈕小於 40dp。 我不想通過增加按鈕的高度來解決這個問題。

您可以設置Insets屬性,因此在您的按鈕中添加:

android:insetTop="0dp"
android:insetBottom="0dp"

如果需要,還有insetLeftinsetRight

暫無
暫無

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

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