欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android的ImageButton當(dāng)顯示Drawable圖片時(shí)就不顯示文字

 更新時(shí)間:2013年06月02日 16:21:18   作者:  
Android提供的ImageButton當(dāng)顯示Drawable圖片時(shí)就不會(huì)再顯示文字了,下面與大家分享下3種解決方法,不會(huì)的朋友可以了解下哈
很多人對(duì) Android提供的ImageButton有個(gè)疑問,當(dāng)顯示Drawable圖片時(shí)就不會(huì)再顯示文字了,其實(shí)解決的方法有三種:

第一種:就是圖片中就寫入文字,但是這樣解決會(huì)增加程序體積,同時(shí)硬編碼方式會(huì)影響多國語言的發(fā)布。
第二種:解決方法很簡單,通過分析可以看到ImageButton的 layout,我們可以直接直接繼承,添加一個(gè)TextView,對(duì)齊方式為右側(cè)即可實(shí)現(xiàn)ImageButton支持文字右側(cè)顯示。
第三種:更簡潔效率的方法:使用Button ,然后設(shè)定Button 的 android:drawableLeft 等屬性即可。示例:
復(fù)制代碼 代碼如下:

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/icon"
android:text="按鈕"
/>

第四種:用布局多封一層
復(fù)制代碼 代碼如下:

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/bt">
<ImageView
android:id="@+id/ib"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ringlove"
android:background="#00000000"
/>
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cs"
android:paddingLeft="20px"
/>
</LinearLayout>

相關(guān)文章

最新評(píng)論