我有一个页脚,我需要水平放置我的3个按钮(左,中,右 - 就像我将每个按钮的屏幕宽度分成3个,但按钮之间有边距)。我需要放一个图像来覆盖每个按钮,按钮应该具有我的图像所具有的形状(不缩放)。我遇到的问题是,我使用图像按钮将图像放在每个按钮上,当我更换设备以查看它的样子时,我看到我的按钮缩放了。这太烦人了,我真的不知道该怎么办。我用weightum。我的代码是这样的:
<RelativeLayout
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="15dp"
android:layout_alignParentBottom="true"
android:background="@color/black">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton1"
android:background="@drawable/image1"
android:layout_gravity="left"
android:layout_marginRight="20dp"
android:layout_weight="1"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton2"
android:background="@drawable/image2"
android:layout_gravity="left"
android:layout_marginRight="20dp"
android:layout_weight="1"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton3"
android:background="@drawable/image3"
android:layout_gravity="right"
android:layout_weight="1"/>
</LinearLayout>
</RelativeLayout>
即使这样,在我当前的设备中,我必须在按钮之间放置特定的边距,以便看不到缩放的图像。而且我不确定它们最后是否会缩放。
我希望有一种解决方案可以让我能够在任何设备中缩放3个图像,并根据每个设备的大小在每个设备中拥有它们应具有的余量。
非常感谢你!!