你好。
有CardView,里面有TextView。自我CardView包裹在ScrollView:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="50dp"
android:layout_marginLeft="50dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
android:text="здесь большой текст"/>
</android.support.v7.widget.CardView>
</ScrollView>
正如您从标记代码中看到的那样,CardView左边距和右边距已添加 - 它们确实正确显示。
它需要添加到CardView顶部和底部的边距。
添加android:layout_marginTop到CardView导致在顶部添加边距,但在这种情况下ScrollView它不会将内容滚动到底部。
添加android:layout_marginBottom到CardView根本不会进行任何更改。
请告诉我如何正确添加这些字段。
附言。标记实际上要复杂得多,只是一个最小的可重现示例。
您需要一个额外的容器。
那些。在 ScrollView 中放置一些东西,例如 FrameLayout,您需要为其设置必要的填充,并且已经将 CardView 放入其中。或者已经为 CardView 分配边距。