1
我想製作一個ImageButton放入我的應用程序,但我需要一個非常特定的。如何在XML中創建此按鈕?
我想作一個ImageButton的類似於一個在下載快的。注意左邊的截圖,相機。看看這裏有一張圖片,底部有一個半透明的灰色條紋,裏面有文字?我想製作一些非常相似的東西,但是在灰色條中有一個大的文本視圖,而不是兩個小的文本視圖。我完全失去了如何在XML中這樣做,所以如果有人可以幫助我,它將不勝感激。謝謝!
我想製作一個ImageButton放入我的應用程序,但我需要一個非常特定的。如何在XML中創建此按鈕?
我想作一個ImageButton的類似於一個在下載快的。注意左邊的截圖,相機。看看這裏有一張圖片,底部有一個半透明的灰色條紋,裏面有文字?我想製作一些非常相似的東西,但是在灰色條中有一個大的文本視圖,而不是兩個小的文本視圖。我完全失去了如何在XML中這樣做,所以如果有人可以幫助我,它將不勝感激。謝謝!
你的意思是這樣的嗎? :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/ic_launcher" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/imageButton1"
android:layout_alignLeft="@+id/imageButton1"
android:layout_alignRight="@+id/imageButton1"
android:background="#33000000"
android:text="Image Text" />
</RelativeLayout>
此外,您可以指定的TextView的重力和TEXTSIZE,以進一步滿足您的需求:
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/imageButton1"
android:layout_alignLeft="@+id/imageButton1"
android:layout_alignRight="@+id/imageButton1"
android:background="#33000000"
android:gravity="center_horizontal"
android:text="Image Text"
android:textSize="8sp" />
它的工作原理,但TextView的水平延伸出,以遠按鈕的功能。有什麼辦法解決這個問題? – user1798956
已編輯的答案應該符合您的需求。 – MattMatt
非常感謝你! – user1798956