如何在Android中为RecyclerView制作一个好的网格行项目?
我正在尝试创建一个生日提醒应用程序,我在MainActivity one RecyclerView上有一个物品网格视图。看起来是这样的: 我已经将TextView内部最大化为5个字符,以减少它,并且不超过此注释。如果不将TextView的字符数最大化为5个字符并使其看起来更好,我如何做到这一点 这是我的如何在Android中为RecyclerView制作一个好的网格行项目?,android,android-layout,grid,android-recyclerview,Android,Android Layout,Grid,Android Recyclerview,我正在尝试创建一个生日提醒应用程序,我在MainActivity one RecyclerView上有一个物品网格视图。看起来是这样的: 我已经将TextView内部最大化为5个字符,以减少它,并且不超过此注释。如果不将TextView的字符数最大化为5个字符并使其看起来更好,我如何做到这一点 这是我的网格\u行\u项的布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="htt
网格\u行\u项的布局
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardBackgroundColor="#00000000"
card_view:cardElevation="0.01dp">
<RelativeLayout
android:background="@android:color/transparent"
android:id="@+id/top_layout"
android:layout_width="match_parent"
android:layout_height="140dp">
<ImageView
android:background="@drawable/note3"
android:id="@+id/img_thumbnail"
android:layout_width="320dp"
android:layout_height="180dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<helper.CustomTextView
android:id="@+id/first_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test"
android:textColor="#000000"
android:textSize="18sp"
android:maxLength="7"
android:ellipsize="end"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="48dp" />
<helper.CustomTextView
android:id="@+id/last_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test"
android:textSize="18sp"
android:maxLength="6"
android:ellipsize="end"
android:textColor="#000000"
android:layout_below="@+id/first_name"
android:layout_alignLeft="@+id/first_name"
android:layout_alignStart="@+id/first_name" />
<TextView
android:id="@+id/date_of_birthday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>
<TextView
android:id="@+id/gender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
另外,我想指出的是,该网格项目看起来非常小,内部的文本不太可见。您可以看到问题是您倾斜了post-it notes图像,并且希望将文本放置在中心。我的建议是在一个画包中打开图像,在里面画一个矩形,这样你可以得到一个文本应该放在里面的参考。你也可以将textview旋转到与图像相同的角度,这样它看起来正确,并且可以避免溢出--