我在一张桌子的布局里有两张硬纸板。代码:
<TableLayout android:id="@+id/TableLayout01" android:stretchColumns="*"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:layout_centerInParent="true"
android:layout_below="@+id/card_view3"
android:layout_marginTop="7dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp">
<TableRow android:id="@+id/TableRow01" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1">
<android.support.v7.widget.CardView
android:layout_margin="5dp" android:layout_weight="1"
android:layout_height="180dp" android:layout_width="fill_parent"
android:background="#ffdbff3d">
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_margin="5dp" android:layout_weight="1"
android:layout_height="180dp" android:layout_width="fill_parent"
android:background="#ffdbff3d">
</android.support.v7.widget.CardView>
</TableRow>
</TableLayout>cv1内部有一张图片,问题是当我将图片(在cv1中)的宽度设置为fill_parent时,图片占据了所有的行,并且不会只填充cv1,甚至当我没有设置fill家长来完成它的任务时!
我甚至不能为我的简历设定背景,我也不知道为什么。
我希望你能解决这个问题。
发布于 2015-08-04 16:07:42
没有必要使用TableLayout,它的性能很差。解决方案:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.v7.widget.CardView
android:layout_width="0dp"
android:layout_height="180dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#ffdbff3d" />
<android.support.v7.widget.CardView
android:layout_width="0dp"
android:layout_height="180dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#ffdbff3d" />
</LinearLayout>更糟糕的是--如果您使用权重而不是指定它会影响什么属性,那么在这种情况下,应该将其设置为layout_width,因此应该将其设置为"0dp"。
https://stackoverflow.com/questions/31808547
复制相似问题