为了账号安全,请及时绑定邮箱和手机立即绑定

如何在 CardView 中获得红色的空白空间?

如何在 CardView 中获得红色的空白空间?

翻过高山走不出你 2021-12-10 15:22:37
亲爱的 Android 开发人员,我正在创建 cv Android 应用程序,但是 CardView 中的 TextView 之后是空的,我该如何摆脱那个空间在我的 xml 代码下面,我已经将 CardView 作为父子实现为 LinearLayout。<?xml version="1.0" encoding="utf-8"?><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:layout_width="match_parent"    android:layout_height="match_parent"    card_view:cardCornerRadius="0dp"    card_view:cardPreventCornerOverlap="true"    card_view:cardUseCompatPadding="true">    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:orientation="vertical">        <ImageView            android:id="@+id/imageView"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:layout_margin="30dp"            android:scaleType="centerCrop" />        <Space            android:layout_width="50dp"            android:layout_height="20dp" />        <TextView            android:id="@+id/about"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:layout_marginTop="16dp"            android:layout_marginRight="250dp"            android:gravity="center"            android:text="@string/about_me"            android:textSize="16sp"            android:textStyle="bold" />        <TextView            android:id="@+id/introduction"            android:layout_width="match_parent"            android:layout_height="match_parent"            android:layout_marginTop="16dp"            android:gravity="start" />    </LinearLayout></android.support.v7.widget.CardView>
查看完整描述

3 回答

?
天涯尽头无女友

TA贡献1831条经验 获得超9个赞

减少文本视图的边距顶部也删除空间标签并减少图像视图的边距


查看完整回答
反对 回复 2021-12-10
?
桃花长相依

TA贡献1860条经验 获得超8个赞

将卡片视图的布局高度更改为 match_parent


查看完整回答
反对 回复 2021-12-10
?
米脂

TA贡献1836条经验 获得超3个赞

在您的卡片视图中使用此属性,您可以看到不同之处


您的卡片没有高度和半径,并且卡片视图合并到活动中,这就是为什么它在文本后显示为空格的原因在卡片视图中使用它:


 <?xml version="1.0" encoding="utf-8"?>


    <RelativeLayout 

        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:layout_margin="8dp">


        <android.support.v7.widget.CardView 

            xmlns:android="http://schemas.android.com/apk/res/android"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            card_view:cardCornerRadius="8dp"

            card_view:cardElevation="6dp"

            android:elevation="4dp">


              <LinearLayout 

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:layout_marginBottom="8dp"

                android:orientation = "vertical">


            <ImageView

                android:id="@+id/imageView"

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:layout_margin="30dp"

                android:scaleType="centerCrop" />


            <TextView

                android:id="@+id/about"

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:layout_marginTop="16dp"

                android:layout_marginRight="250dp"

                android:gravity="center"

                android:text="@string/about_me"

                android:textSize="16sp"

                android:textStyle="bold" />


            <TextView

                android:id="@+id/introduction"

                android:layout_width="match_parent"

                android:layout_height="match_parent"

                android:layout_marginTop="16dp"

                android:gravity="start" />


        </LinearLayout>


    </android.support.v7.widget.CardView>

    </RelativeLayout>


查看完整回答
反对 回复 2021-12-10
  • 3 回答
  • 0 关注
  • 171 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号