我有一组水平布局的按钮.我已经设置了一个可绘制的图像作为每个按钮的背景.但是当我使线性布局跨越屏幕宽度时,按钮会失去纵横比.我希望保持其宽高比不变.我的意思是我必须在整个应用程序中保持它的方形形状,无论屏幕分辨率如何.我怎样才能做到这一点.任何建议表示赞赏.
这是我的XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/main_background"
android:baselineAligned="false"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/answer_bg"
android:padding="10dip" >
<Button
android:id="@+id/b2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/img_background"
android:height="50dip"
android:text="@string/x"
android:textStyle="bold" />
<Button
android:id="@+id/b3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/img_background"
android:height="50dip"
android:text="@string/x"
android:textStyle="bold" />
<Button
android:id="@+id/b4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/img_background"
android:height="50dip"
android:text="@string/x"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
谢谢