我正在使用一些图像按钮开发xml,图像按钮在模拟器中正确显示但它在Disorganization上
设备(例如galaxy fit)
如模拟器中所述https://www.dropbox.com/s/qeecp868ht61sck/emulator.jpg和galaxy fit https://www.dropbox.com/s/23r9tvtp0tcn7bs/fit.jpg
什么改变imagebutton与尺寸设备成比例?
我能做什么?
这是我的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" tools:context=".Main" android:background="@drawable/backmain" > <ImageButton android:id="@+id/btnfehrest" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="53dp" android:background="@null" android:src="@drawable/fehrest" /> <ImageButton android:id="@+id/btndarbareh" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/btnfehrest" android:layout_marginLeft="21dp" android:background="@null" android:src="@drawable/darbareh" /> <ImageButton android:id="@+id/btnmahsulat" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignTop="@+id/btndarbareh" android:layout_marginRight="17dp" android:background="@null" android:src="@drawable/mahsulat" /> <ImageButton android:id="@+id/btnkhoruj" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/btndarbareh" android:layout_centerHorizontal="true" android:background="@null" android:src="@drawable/khoruj" /> <FrameLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/main" android:scaleType="fitXY" /> </FrameLayout> </RelativeLayout>I am develop xml with some image button,image buttons show properly in emulator but it Disorganization on
devices(for example galaxy fit)
As described in emulator https://www.dropbox.com/s/qeecp868ht61sck/emulator.jpg and galaxy fit https://www.dropbox.com/s/23r9tvtp0tcn7bs/fit.jpg
what change imagebutton Proportional to size device?
what can i do?
this is my 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" tools:context=".Main" android:background="@drawable/backmain" > <ImageButton android:id="@+id/btnfehrest" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="53dp" android:background="@null" android:src="@drawable/fehrest" /> <ImageButton android:id="@+id/btndarbareh" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/btnfehrest" android:layout_marginLeft="21dp" android:background="@null" android:src="@drawable/darbareh" /> <ImageButton android:id="@+id/btnmahsulat" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignTop="@+id/btndarbareh" android:layout_marginRight="17dp" android:background="@null" android:src="@drawable/mahsulat" /> <ImageButton android:id="@+id/btnkhoruj" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/btndarbareh" android:layout_centerHorizontal="true" android:background="@null" android:src="@drawable/khoruj" /> <FrameLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/main" android:scaleType="fitXY" /> </FrameLayout> </RelativeLayout>最满意答案
这完全是因为您在xml中使用了相对布局
相对布局始终与父视图或子视图保持xml中其他视图的关系。
所以在小屏幕上你的FrameLayout按钮图像试图适应屏幕,因为它保持与其他视图的关系,这就是它重叠的原因。
谈论对此提出建议 。
1)您可以使用滚动视图使用线性布局 ,即如果视图超出屏幕,您可以通过向下滚动查看它们。
//如果你不想这样做
2)您可以在layout-small中创建另一个具有相同名称的xml。 例:
res> layout> main.xml
和
res> layout-small> main.xml
第二个选项将帮助您为不同的屏幕尺寸创建多种支持。
注意:默认布局 - 小文件夹不存在但您可以创建它。
It is all because you are using Relative Layout in your xml
Relative layout always maintains a relationship with other views in your xml either with Parent view or with child views.
so on small screen your FrameLayout with button image trying to fit in the screen as it maintaining the relationship with other views, that's why its overlaping.
Talking about giving the suggestion regarding this.
1) You can use Linear Layout with scroll view, ie if views gets out of screen you can see them by scrolling down.
//If you don't wanna do this
2) You can create another xml in layout-small with same name. Example:
res> layout> main.xml
and
res> layout-small> main.xml
Second option will help you in creating multi support for different screen sizes.
Note: By Default layout-small folder is not present but you can create it.
更多推荐
发布评论