第一次问一个问题,所以请温柔。 :)
我试图在ImageView
内创建LinearLayout
s的嵌套版式。父LinearLayout
需要匹配根视图的宽度,但其高度由其保存的2 ImageView
个组件决定。
2个ImageView
分量需要对LinearLayout
父级内的宽度(即50%)进行相等加权,并保持其比例高度。
然而,虽然ImageView
s的宽度正确计算且图像本身的高度正确,但父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>
这就是我的目标
任何帮助都会非常感激,对任何礼仪失败表示道歉,
丹尼