Android 如何在嵌套的ScrollView中按比例安装CardView
我正在尝试使用cardview创建一个“表”2行1列,到目前为止,我有: 但我想那样 紫色属于Android 如何在嵌套的ScrollView中按比例安装CardView,android,android-cardview,Android,Android Cardview,我正在尝试使用cardview创建一个“表”2行1列,到目前为止,我有: 但我想那样 紫色属于RelativeLayout而黑色属于NestedScrollView,我需要使这些卡片沿着布局伸展,并且在底部不留任何间隙,它必须与顶部的方式相同。 我的代码: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk
RelativeLayout
而黑色属于NestedScrollView,我需要使这些卡片沿着布局伸展,并且在底部不留任何间隙,它必须与顶部的方式相同。
我的代码:
<RelativeLayout 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/content_painel"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.org.barros.test.Painel"
tools:showIn="@layout/activity_painel">
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:emojicon="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_marginTop="8dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="8dp"
android:visibility="visible">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="8dp"
app:cardBackgroundColor="#4CAF50">
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="56dp"
android:paddingTop="56dp"
emojicon:srcCompat="@mipmap/ic_launcher" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:cardBackgroundColor="#4CAF50">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="56dp"
android:paddingTop="56dp"
emojicon:srcCompat="@mipmap/ic_launcher" />
</android.support.v7.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="8dp"
app:cardBackgroundColor="#009688">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="56dp"
android:paddingTop="56dp"
emojicon:srcCompat="@mipmap/ic_launcher"
android:id="@+id/imageView" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:cardBackgroundColor="#2196F3">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="56dp"
android:paddingTop="56dp"
emojicon:srcCompat="@mipmap/ic_launcher" />
</android.support.v7.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="8dp"
app:cardBackgroundColor="#009688">
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="56dp"
android:paddingTop="56dp"
emojicon:srcCompat="@mipmap/ic_launcher" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:cardBackgroundColor="#2196F3">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="56dp"
android:paddingTop="56dp"
emojicon:srcCompat="@mipmap/ic_launcher" />
</android.support.v7.widget.CardView>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
为什么不使用网格视图呢?如果您能帮助我,我将非常感谢您在NestedScrollView中尝试了android:layout\u height=“wrap\u content”而不是android:layout\u height=“match\u parent”?您到底面临什么问题?只是想去掉空白??是的,我想去掉它底部的空白,和上面的一样。有些东西,上面和下面是相同的填充物