第一次提问,请温柔些。 :)
我正在尝试在LinearLayout
中创建嵌套的ImageView
布局。父级LinearLayout
需要与根视图的宽度匹配,但高度由它所持有的2个ImageView
组件决定。
这2个ImageView
组件需要在LinearLayout
父级内等分宽度(即50%),并保持其比例高度。
然而,虽然ImageView
的宽度计算正确且图像本身的高度正确,但父级LinearLayout
的高度不正确。
以下是我正在使用的XML代码,很抱歉,但我目前没有足够的声望点数来发布图片,这可能会让事情变得困难。
XML 代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/grey"
android:orientation="vertical"
android:padding="10dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:background="@drawable/container_dropshadow"
android:orientation="horizontal"
android:padding="5dp"
android:weightSum="2" >
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:padding="5dp"
android:src="@drawable/barcode" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:padding="5dp"
android:src="@drawable/barcode" />
</LinearLayout>
</LinearLayout>
这是我得到的东西
非常感谢您的帮助,如果有任何失礼之处,请见谅。
Danny