We are showing some text in our application (say in a RecyclerView
with GridLayoutManager
). This text is shown in different languages as highlighted in the image below. Due to this, the height of TextView
is different as different language fonts are taking different spacing.
Please refer to the sample image below and the required code to draw the text view.
<com.google.android.material.textview.MaterialTextView
android:id="@ id/tv_title_one"
android:layout_width="0dp"
app:layout_constraintWidth_percent="0.5"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:fontFamily="@font/lato_bold"
android:gravity="start"
android:maxLines="3"
android:minLines="1"
android:singleLine="false"
android:includeFontPadding="false"
android:textColor="#541388"
android:letterSpacing="0"
android:lineSpacingExtra="0dp"
android:textSize="32sp"
android:textStyle="normal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Class 12th (Biology) 2021 - 2022" />
Dummy layout with two similar text views but with different language
Please let me know if there is anything missing in the problem description. Thanks for your valuable feedback.
Update #1: Since there is no direct answer to it. We are going with making card height and text height-restricted as mentioned in the accepted answer.
CodePudding user response:
I just think that the reason could come from the font you are trying to use for rending text in this TV. For every language, the character size maybe vary a bit from width to height due to the language specs.
Could you try to use the default system font to check if you still have that spacing issue?
Or another suggestion would be:
- Use
autoSizeMaxTextSize
,autoSizeMinTextSize
feature to allow text size being automatically resize to fix thetextview
when possible. - Apply a fix Height for your text content with extra Vertical Space, and add
android:ellipsize
as your wish.
Still wonder:
- Is your app displaying multiple language at a same time on UI?