Android 从cardview中删除额外空间
我在下面创建了一个cardview 我的代码是:-Android 从cardview中删除额外空间,android,cardview,Android,Cardview,我在下面创建了一个cardview 我的代码是:- <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/card_view" android:layout_width="match_parent" and
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
card_view:cardCornerRadius="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="160dp"
android:orientation="vertical"
android:weightSum="4">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal">
<ImageView
android:id="@+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:scaleType="centerCrop"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left|bottom"
android:background="@android:drawable/screen_background_dark_transparent"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:textSize="16dp"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="@+id/count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:paddingBottom="@dimen/songs_count_padding_bottom"
android:visibility="invisible"
android:paddingLeft="@dimen/album_title_padding"
android:paddingRight="@dimen/album_title_padding"
android:textSize="@dimen/songs_count" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
我想删除空间左、右、上、下的额外空间,如下图所示:-
我怎么做dis?android:layout\u margin 在视图的4侧指定额外空间 从您的XML中删除以下属性
android:layout_margin="5dp".
编辑
<ImageView
android:id="@+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:scaleType="centerCrop" //REMOVE this
/>
从
cardwiew
中删除android:layout\u margin=“5dp
”尝试以下代码:
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="160dp"
android:orientation="vertical"
android:weightSum="4">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal">
<ImageView
android:id="@+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:scaleType="centerCrop"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left|bottom"
android:background="@android:drawable/screen_background_dark_transparent"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:textSize="16dp"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="@+id/count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:paddingBottom="@dimen/songs_count_padding_bottom"
android:visibility="invisible"
android:paddingLeft="@dimen/album_title_padding"
android:paddingRight="@dimen/album_title_padding"
android:textSize="@dimen/songs_count" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
cardwiew
中的android:layout\u margin=“5dp”可能是问题我也会删除它,但什么都没有changed@ManishaKhatke清理重建并运行,确保RecyclerView没有任何边距或padding@ManishaKhatke删除android:scaleType=“centerCrop”并添加android:scaleType=“fitXY”
.ImageView部分。我已将其删除,但没有任何更改请在删除边距后发布屏幕截图。请确保已定义回收器视图的主布局没有边距或填充。如果有,请将其删除。它是在“回收者”视图还是列表视图中?它是在“回收者”视图中发布您的“回收者”视图代码。。也许你在那个版面上留了空白