我有一个ImageButton
,我想在上面显示文本和图像。但是当我尝试模拟器时:
<ImageButton
android:text="OK"
android:id="@+id/buttonok"
android:src="@drawable/buttonok"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
我得到图像但没有文字。如何显示文字?请帮我!
由于您无法使用,android:text
我建议您使用普通按钮并使用复合画板之一。例如:
<Button
android:id="@+id/buttonok"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/buttonok"
android:text="OK"/>
您可以通过把绘制无论你想:drawableTop
,drawableBottom
,drawableLeft
或drawableRight
。
更新
对于按钮,这也很好用。推杆android:background
很好!
<Button
android:id="@+id/fragment_left_menu_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_bg"
android:text="@string/login_string" />
我刚遇到这个问题,并且运行良好。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句