首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CardView内部TableLayout

CardView内部TableLayout
EN

Stack Overflow用户
提问于 2015-08-04 11:50:22
回答 1查看 2.6K关注 0票数 0

我在一张桌子的布局里有两张硬纸板。代码:

代码语言:javascript
复制
                <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家长来完成它的任务时!

我甚至不能为我的简历设定背景,我也不知道为什么。

我希望你能解决这个问题。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-08-04 16:07:42

没有必要使用TableLayout,它的性能很差。解决方案:

代码语言:javascript
复制
<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"

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31808547

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档