0

这可以做到吗?

<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" />
4

1 回答 1

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.
于 2012-06-14T18:15:10.630 回答