可以这样做吗?
<ImageButton
android:id="@+id/test_button"
android:layout_width="70% of screen width"
android:layout_height="whatever is needed for the image to keep its original aspect ratio"
android:background="@drawable/image" />
答案 0 :(得分:0)
你应该能够使用这样的东西:
<ImageButton
android:id="@+id/test_button"
android:layout_width="200dp" // You can use any number here to use a specific size
// You can use dp for density independent pixels
// Or sp for screen independent pixels
android:layout_height="wrap_content" // This will set the height to a size just big
// enough to hold the image.