【发布时间】:2019-03-19 18:43:45
【问题描述】:
我的代码是:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp">
<View
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_gravity="center"
android:background="#00ff00"/>
</android.support.v7.widget.CardView>
【问题讨论】:
-
只需从您的父视图中删除这两行...
android:layout_marginLeft="30dp" android:layout_marginRight="30dp" -
@GowthamanM 的想法是在父母身上有边距,在孩子身上没有
-
从逻辑上思考它会如何发生..child 将根据父属性执行..