Controlling button image aspect ratios in xml

Can this be done?

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

Answers


You should be able to use something like this:

<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.

Need Your Help

AS3: Accessing global variables

actionscript-3 global-variables packages

i'm confused with the term "global" in AS3. within my main controller class, i've defined a variable (myNum) which i would like to access throughout all class .as files within the same package.