亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 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 關注
  • 168 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號