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

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

GridView項彼此重疊

GridView項彼此重疊

素胚勾勒不出你 2021-04-07 13:14:40
請檢查我所附的圖片。產品名稱超過一行時,我將面臨此問題。我很困惑,現在該怎么辦。在我的gridview中,我正面臨著這個問題。我該如何解決?這是我的gridview xml代碼。<GridView    android:id="@+id/productGrid"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:numColumns="2"    android:verticalSpacing="4dp"    android:horizontalSpacing="3dp"    android:focusable="true"    android:stretchMode="columnWidth"    android:fitsSystemWindows="true"></GridView>這是我的網格項xml<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    xmlns:app="http://schemas.android.com/apk/res-auto">    <android.support.v7.widget.CardView        android:id="@+id/card"        android:layout_width="match_parent"        android:layout_height="wrap_content"        app:cardCornerRadius="8dp"        app:cardPreventCornerOverlap="true"        app:contentPadding="8dp">        <LinearLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:orientation="vertical">            <ImageView                android:id="@+id/iv_productImage"                android:layout_width="80dp"                android:layout_height="80dp"                android:layout_gravity="center"                android:src="@drawable/avatar"/>            <TextView                android:id="@+id/tv_productName"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:layout_marginTop="8dp"                android:gravity="center"                android:layout_gravity="center"                android:text="Bread Trimmer"                android:textSize="17sp"                android:textStyle="bold"/>這是單個項目。我很困惑我在哪里犯錯了。請幫忙。謝謝。
查看完整描述

2 回答

?
忽然笑

TA貢獻1806條經驗 獲得超5個贊

解決方案1

您可以將此屬性添加到您的 tv_productName

    android:ellipsize="end"
    android:singleLine="true"
    android:maxLines="1"

此行將...添加到TextView文本的末尾

解決方案2

將此庫用于您的tv_productNameTextView

autofittextview

該庫適合您的TextView大小,以防止重疊

解決方案3

這是一個不好的解決方案,但它可以正常工作,您可以將邊距添加到父布局(RelativeLayout)

android:layout_margin="5dp"


查看完整回答
反對 回復 2021-04-21
?
縹緲止盈

TA貢獻2041條經驗 獲得超4個贊

我認為是問題所在。您的文本視圖。產品名稱。隨著產品名稱的增加,整個文本視圖將被分割并垂直分布。像水鉆玫瑰手表一樣,手表處于與上面的文字相關的垂直位置,這是造成問題的原因。我猜。嘗試使用小文本并檢查這是否是問題,如果那是問題,您可以輕松解決它,我想,請讓我知道它是否有效。謝謝 。


查看完整回答
反對 回復 2021-04-21
  • 2 回答
  • 0 關注
  • 392 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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