Android CardView在顶部留有间隙
左边是我希望我的应用程序的外观,以及它在android studio预览版上的外观。图像与CardView顶部对齐 右边是它的实际外观。有空隙 我尝试了线性布局和相对布局。不起作用。 这是我的密码: 编辑:Android CardView在顶部留有间隙,android,user-interface,android-relativelayout,android-cardview,Android,User Interface,Android Relativelayout,Android Cardview,左边是我希望我的应用程序的外观,以及它在android studio预览版上的外观。图像与CardView顶部对齐 右边是它的实际外观。有空隙 我尝试了线性布局和相对布局。不起作用。 这是我的密码: 编辑: 试试这样的方法: <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <ImageView andr
试试这样的方法:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_margin="20dp"
android:src="@mipmap/ic_launcher"/>
</RelativeLayout>
试试这样的方法:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_margin="20dp"
android:src="@mipmap/ic_launcher"/>
</RelativeLayout>
您是否尝试过像android:layout_marginRight=“-10dp”这样的负边距?此外,您还可以尝试将
CardView
和ImageView放入RelativeLayout
作为一种解决办法。您是否尝试过像android:layout\u marginRight=“-10dp”
这样的负边距?此外,您还可以尝试将CardView
和ImageView放入RelativeLayout
作为解决办法。使用负边距无效:
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/testCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/medium_margin"
android:layout_marginRight="@dimen/medium_margin"
android:animateLayoutChanges="true"
app:cardCornerRadius="3dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/fullCardLayout"
android:layout_width="match_parent"
android:layout_height="@dimen/reward_card_height"
android:orientation="horizontal"
android:layout_marginTop="-5dp"
android:paddingLeft="@dimen/medium_margin"
>
<ImageView
android:id="@+id/imgProvider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/tiny_margin"
android:src="@mipmap/rewards_amazon_icon"/>[![enter image description here][1]][1]
[![在此处输入图像描述][1][1]
使用负边距无效:
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/testCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/medium_margin"
android:layout_marginRight="@dimen/medium_margin"
android:animateLayoutChanges="true"
app:cardCornerRadius="3dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/fullCardLayout"
android:layout_width="match_parent"
android:layout_height="@dimen/reward_card_height"
android:orientation="horizontal"
android:layout_marginTop="-5dp"
android:paddingLeft="@dimen/medium_margin"
>
<ImageView
android:id="@+id/imgProvider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/tiny_margin"
android:src="@mipmap/rewards_amazon_icon"/>[![enter image description here][1]][1]
[![在此处输入图像描述][1][1]
尝试使用此标签
card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="true"
尝试使用此标签
card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="true"
您是否尝试将页边距顶部和左侧设置为ImageView?是否可以发布所有xml?是的,出于某种原因,它不包括CardView,现在我从开始一直发布到图像视图部分,您是否尝试将页边距顶部和左侧设置为ImageView?是否可以发布所有xml?是的,出于某种原因,它不包括CardView,现在我从一开始就发布了,直到图像视图部分,嘿@Alexander,它们都不起作用。第一张卡缩小了卡外的间隙。第二个没用嘿,亚历山大,两个都没用。第一张卡缩小了卡外的间隙。第二个没用