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
You should use linearlayout and than set all imagebutton's layout_weight attr to 0.25 Linearlayout must be in the parent bottom.
Like this;
<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>
将您的layout_width属性设置为“ fill_parent”并确保scaleType为fitXY
Use equal weight attribute in our ImageButtons. It will occupy the space as compare to Screen Sizes, and use dp not dip.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.