相关疑难解决方法(0)

Android CardView删除填充

如何在下面的布局中摆脱这个奇怪的填充:

在此输入图像描述

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@color/ColorPrimaryDark">

    <android.support.v7.widget.CardView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        card_view:cardCornerRadius="10dp"
        android:layout_marginTop="9dp"
        android:layout_marginLeft="9dp"
        android:layout_marginRight="9dp"
        card_view:cardElevation="0.01dp"
        android:layout_marginBottom="0dp"
        card_view:cardPreventCornerOverlap="true"
        card_view:cardUseCompatPadding="true"
        card_view:cardBackgroundColor="@color/ColorPrimary">

        <RelativeLayout
            android:id="@+id/top_layout"
            android:layout_width="fill_parent"
            android:layout_height="180dp"
            android:background="@color/ColorPrimary">

            <ImageView
                android:id="@+id/img_thumbnail"
                android:layout_width="fill_parent"
                android:layout_height="180dp"
                android:scaleType="fitXY"
                android:background="@drawable/korabltest"/>

            <RelativeLayout
                android:id="@+id/inner_layout"
                android:layout_width="fill_parent"
                android:layout_height="36dp"
                android:background="#5c1b1b1b"
                android:layout_gravity="bottom"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true">

                <TextView
                    android:id="@+id/tv_nature"
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:paddingLeft="5dp"
                    android:paddingRight="5dp"
                    android:layout_gravity="bottom"
                    android:gravity="center_vertical"
                    android:alpha="0.8"
                    android:textColor="#fff"
                    android:textSize="18sp"
                    android:text="Lexington"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentStart="true" />

                <TextView
                    android:id="@+id/tv_nature_1"
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:paddingLeft="5dp"
                    android:paddingRight="5dp"
                    android:layout_gravity="bottom"
                    android:gravity="center_vertical"
                    android:alpha="0.8"
                    android:textColor="#fff"
                    android:textSize="18sp"
                    android:textStyle="bold"
                    android:text="527 (31%)"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentRight="true"
                    android:layout_alignParentEnd="true" />
            </RelativeLayout>
        </RelativeLayout>
    </android.support.v7.widget.CardView>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android android-cardview

33
推荐指数
3
解决办法
2万
查看次数

NestedScrollView中的CardView在底部显示额外的空间

我有一些布局问题.我将一个cardView放在NestedScrollView中,完全放在CoordinatorLayout中.并且,它在底部添加了大量填充.有人可以解释为什么会发生这种情况.我知道cardView在下面的L设备中使用额外的填充来显示圆角和阴影,但是它需要这么多的填充,而且也只需要在底部.

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="com.startup.practice.getplaced.activities.InfoEventDetails">
    <android.support.design.widget.AppBarLayout
        android:id="@+id/info_event_details_appbar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/content_image_height"
        android:theme="@style/AppTheme.AppBarOverlay"
        >
        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/info_event_details_collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp">
            <ImageView
                android:src="@drawable/manhattan_college_logo"
                android:scaleType="centerCrop"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_collapseMode="parallax"/>
            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/sheet_text_scrim_height_top"
                android:background="@drawable/scrim_top"
                app:layout_collapseMode="pin"/>
            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/sheet_text_scrim_height_bottom"
                android:layout_gravity="bottom"
                android:layout_alignBottom="@+id/image"
                android:background="@drawable/scrim_bottom"/>
            <android.support.v7.widget.Toolbar
                android:id="@+id/info_event_details_appbar_toolbar"
                app:layout_collapseMode="pin"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:popupTheme="@style/AppTheme.PopupOverlay"/>
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>
    <android.support.v4.widget.NestedScrollView>
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <RelativeLayout
                android:layout_margin="@dimen/activity_horizontal_margin"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <TextView
                    android:id="@+id/info_event_details_date"
                    android:text="12th July"
                    android:layout_alignParentRight="true"
                    android:textSize="@dimen/date_text_size"
                    android:textColor="#90000000"
                    android:textStyle="bold"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    />
                <TextView
                    android:id="@+id/info_event_details_title"
                    android:layout_toLeftOf="@id/info_event_details_date"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Attention! Students …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-cardview android-nestedscrollview

3
推荐指数
1
解决办法
3075
查看次数