繁体   English   中英

用于不同屏幕尺寸的imagebutton

[英]imagebutton for different screen size

我在支持ImageButton的屏幕尺寸时遇到问题。
添加ImageButton时,图像远大于屏幕尺寸,并且一半超出屏幕限制。
我尝试通过更改每个图像的大小来进行尝试,但是在(4英寸屏幕尺寸)下,图像看起来比其他屏幕尺寸要小。

有什么办法可以使我从xml,而不是将许多diffetet大小添加到dpi文件夹

希望有人可以提供帮助。
非常感谢

main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:paddingBottom="@dimen/activity_vertical_margin"
   android:paddingLeft="@dimen/activity_horizontal_margin"
   android:paddingRight="@dimen/activity_horizontal_margin"
   android:paddingTop="@dimen/activity_vertical_margin"
   android:background="@drawable/walla"
   tools:context=".MainActivity" >

<FrameLayout
   android:id="@+id/frameLayout1"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:layout_alignParentBottom="true"
   android:layout_centerHorizontal="true" >

   <ImageButton
     android:id="@+id/imageButton1"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:layout_marginBottom="154dp"
     android:background="@null"
     android:src="@drawable/hex_button_one" />

</FrameLayout>

</RelativeLayout>

这就是为什么制作了不同的dpi文件夹,以便图像每次在不同的屏幕上都会更改大小的原因。.确保将其放在图像的右侧文件夹中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM