0

i am new to android programming. I have a problem scaling ImageButtons to different screen-resolutions. I made different image sizes based on the dpi and put them into hdpi(120px*72px,160dpi), mdpi(80px*48px,160dpi) and xhdpi(160px*96px,160dpi) But on screen-resolutions like 1280x720 there is a little bit of space on the right side. I tried things like:

android:scaleType="fitXY"
android:scaleType="centerInside"
android:adjustViewBounds="true"

but nothing worked. Also, i am not quite sure what these do. Like i said, i am new to android.

https://www.dropbox.com/sh/dmtcn4lxyxxh5wt/vpq9pBMOSl

<ImageButton
    android:id="@+id/imageButtonsearch"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_toRightOf="@+id/imageButtonshare"
    android:background="@null"
    android:scaleType="centerInside"
    android:src="@drawable/selector_search"
    android:adjustViewBounds="true" />

Thanks in advance

4

3 に答える 3

1

linearlayout を使用し、すべての imagebutton の layout_weight attr を 0.25 に設定する必要があります。 Linearlayout は親の下部にある必要があります。

このような;

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:orientation="horizontal">

    <ImageButton 
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="0.25"
        android:src="@drawable/ic_launcher"/>

    <ImageButton 
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="0.25"
        android:src="@drawable/ic_launcher"/>

    <ImageButton 
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="0.25"
        android:src="@drawable/ic_launcher"/>

    <ImageButton 
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="0.25"
        android:src="@drawable/ic_launcher"/>

</LinearLayout>

于 2013-10-07T12:23:32.110 に答える
0

layout_width 属性を「fill_parent」に設定し、scaleType が fitXY であることを確認します

于 2013-10-07T12:18:56.600 に答える