簡體   English   中英

帶有文本的Android自定義按鈕

[英]Android custom button with text

當您打開Play商店時,我試圖制作一個看起來像頂部4個按鈕的按鈕。 (應用程序,音樂,書籍,電影)一個帶有左右圖像的按鈕,您的文本與該圖像正確對齊。 我的意思是說文本沒有居中。 我一直在嘗試下面的代碼,但這不是我想要的結果。

<Button
        android:id="@+id/contact_website"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:drawableLeft="@drawable/website"
        android:drawablePadding="-20sp"
        android:onClick="website_onClick"
        android:background="@drawable/custom_button"
        android:text="@string/contact_link"/>

有人可以提供幫助嗎?

提前致謝。

刪除-ve填充。

嘗試這個

<Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#123456"
            android:gravity="left|center_vertical"
            android:layout_gravity="center_vertical"
            android:drawablePadding="0sp"
            android:drawableLeft="@drawable/ic_launcher"
            android:text="Button Text"
            android:padding="10dp"
         >
        </Button>

這對我有用

暫無
暫無

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

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