Android Imagebutton使用双嵌套布局权重渲染不正确
使用这些图像: (333x300) (1680x1050) 这个布局:Android Imagebutton使用双嵌套布局权重渲染不正确,android,android-layout,android-xml,Android,Android Layout,Android Xml,使用这些图像: (333x300) (1680x1050) 这个布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center">
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="@drawable/apple" />
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="@drawable/apple" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center">
<ImageButton
style="@style/OtherButton"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="@drawable/orange" />
<ImageButton
style="@style/OtherButton"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="@drawable/orange" />
</LinearLayout>
</LinearLayout>
给出以下结果:
苹果和橙色按钮只有单嵌套布局,大小相同。在与Eclipse混为一谈之后,我注意到当按钮的图像较大时,按钮往往会更高,但相对比例似乎没有遵循特定的模式
为什么按钮的高度不同?是否有其他方法可以根据屏幕分辨率和密度进行缩放?进行以下更改
在您的主父布局中,将布局高度设置为android:Layout\u height=“fill\u parent”谢谢,我通过更改此设置并从按钮的样式定义中删除重复的布局宽度/高度属性来实现此功能。