最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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ā)布。
第二種:解決方法很簡(jiǎn)單,通過分析可以看到ImageButton的 layout,我們可以直接直接繼承,添加一個(gè)TextView,對(duì)齊方式為右側(cè)即可實(shí)現(xiàn)ImageButton支持文字右側(cè)顯示。
第三種:更簡(jiǎn)潔效率的方法:使用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)論

班戈县| 山东省| 苏州市| 佛山市| 辽宁省| 广汉市| 揭阳市| 五原县| 栖霞市| 喀什市| 万荣县| 浮梁县| 游戏| 奈曼旗| 渝北区| 板桥市| 内丘县| 古交市| 沿河| 方山县| 台北县| 黄骅市| 莫力| 前郭尔| 当雄县| 隆子县| 泊头市| 钦州市| 托克托县| 开封市| 拉萨市| 延川县| 武平县| 同仁县| 宜黄县| 什邡市| 同德县| 历史| 陈巴尔虎旗| 城市| 沧州市|