在Android按钮中获取调整大小的图像
我想设计一个带有图标和文本装饰的大按钮的表格布局。我发现了一些类似的问题,但不尽相同。我的简化XML布局是:在Android按钮中获取调整大小的图像,android,image,button,Android,Image,Button,我想设计一个带有图标和文本装饰的大按钮的表格布局。我发现了一些类似的问题,但不尽相同。我的简化XML布局是: <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TableRow a
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow android:id="@+id/TableRow01" android:gravity="center">
<Button android:text="@string/telephone" android:drawableTop="@drawable/phone" android:id="@+id/button_phone"></Button>
<Button android:text="@string/help" android:src="@drawable/help" android:id="@+id/button_help"></Button>
</TableRow>
</TableLayout>
图标图像有点大,所以我想Android调整它们的大小,但是Android:height参数调整按钮的大小,而不是嵌入的图像。你想得到一个文本和图像“可调整大小”的按钮吗?使用ScaleType属性()
编辑:请参阅,以获取有关使用绘图支持多种屏幕尺寸的信息。如果你遵循android的惯例,而不是仅仅尝试使用真正大的drawable,并在运行时为更小的屏幕调整它们的大小,你会有更好的性能和更少的问题 抱歉,scaleType attibute适用于ImageButton,而不是Button。我为没有彻底阅读您的问题而道歉。你不想自己调整可绘制资源的大小是有原因的吗?是的,我想设计一个适用于多个大小屏幕的应用程序,因此我希望Android系统根据显示大小调整可绘制资源的大小。然后你要找的是: