Android xml布局:ScrollView剪切嵌入的CardView项的底部
我在ScrollView中有一个单一的CardView,它可以完美地工作,只要CardView的高度足够小,不需要滚动。但是,如果CardView需要滚动(以便显示更大的图像),则会切断CardView的底部。我做错了什么 以下是my layout.xml文件的一部分:Android xml布局:ScrollView剪切嵌入的CardView项的底部,android,xml,android-layout,scrollview,android-cardview,Android,Xml,Android Layout,Scrollview,Android Cardview,我在ScrollView中有一个单一的CardView,它可以完美地工作,只要CardView的高度足够小,不需要滚动。但是,如果CardView需要滚动(以便显示更大的图像),则会切断CardView的底部。我做错了什么 以下是my layout.xml文件的一部分: <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/andr
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:fillViewport="true" >
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:elevation="8dp"
app:cardCornerRadius="8dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_yellow_lighten_4"
android:nestedScrollingEnabled="false"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView_downloaded"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:scaleType="fitCenter"
android:src="@android:drawable/ic_menu_gallery"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!-- several other TextView elements here not shown -->
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
以下是我找到的解决方案:
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="8dp"
app:cardCornerRadius="8dp"
app:cardUseCompatPadding="true"
>
与问题分享你的整个布局我已经使用上面的代码测试了布局,省略了其他元素。结果(cardView的底部被切掉)是一样的。您是否尝试过在您的
ScrollViewer
中添加android:CliptPadding=“false”和android:clipChildren=“false”
,并对ScrollViewer设置android:layou height=“match\u parent”
使用android:layou height=“wrap\u content”
和android:fillViewPort=true
似乎有点奇怪。你想在那里实现什么?很高兴你能解决它。这个解决方案只会让我想起以前遇到过的情况,但当时我记不得了。孩子被自己的边缘所限制是愚蠢的,但不知何故似乎是合理的。