我有一个屏幕布局,其中包括线性布局(水平)中包含的 3 个 Button 控件。每个按钮都有一个背景图像。请参阅下面的 XML:
<LinearLayout
android:id="@+id/notificationform_llt_ApprovalBtns"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal"
android:paddingLeft="8dp"
android:paddingRight="8dp" >
<Button
android:id="@+id/notificationform_btn_Approve"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="@drawable/btn_approve"
android:onClick="btnApprove_Click" />
<Button
android:id="@+id/notificationform_btn_Reject"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/btn_reject"
android:onClick="btnReject_Click" />
<Button
android:id="@+id/notificationform_btn_Delegate"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="@drawable/btn_delegate"
android:onClick="btnDelegate_Click" />
</LinearLayout>
屏幕在我的 Galaxy W 手机(3.7 英寸)上看起来很棒,但在我的 Nexus 7 上运行时,按钮水平拉伸但不是垂直拉伸,因此看起来被压扁了。如果我理解正确,这两款设备都具有相似的分辨率并且都在寻找图像在存储我的图像的drawable-hdpi文件夹中。我尝试将图像制作为9补丁,但这没有任何区别。如何使图像在高度和宽度上按比例缩放?