android – 卡片视图layout_height =“wrap_content”里面的滚动视图不起作用
作者:互联网
我在滚动视图和内部卡片视图中添加了卡片视图我添加了首选项片段,但它只显示首选项类别标题.
Setting.xml的
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.afollestad.appthemeengine.inflation.ATEToolbar
android:id="@+id/toolbar"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/view"
android:layout_below="@+id/toolbar">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="4dp"
style="?attr/CardTheme" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
任何解决方案
解决方法:
添加android:fillViewport =“true”以填充scrollview.另外不要忘记在scrollview中更改相对布局的高度.将其更改为match_parent和卡片视图的高度(match_parent).
最后布局应该是这样的,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.afollestad.appthemeengine.inflation.ATEToolbar
android:id="@+id/toolbar"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/view"
android:fillViewport="true"
android:layout_below="@+id/toolbar">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardElevation="4dp"
style="?attr/CardTheme" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
标签:android,android-cardview,scrollview 来源: https://codeday.me/bug/20190829/1757708.html