Search code examples
androidkotlinandroid-cardview

Why is the content of my Textview not completely visible in android?


I have displayed Textviews in my cardview but for some sentence it's displaying entire sentence correctly in one line but for other sentence it's displaying only half the content. As you can see here,enter image description here and here enter image description here

as you can see in the images , one of the screenis displaying entire Textview content but other is partially displaying. And you can see, the number of words in both the sentences are equal. Below is my code of my Cardview which is inside a LinearLayout

<androidx.cardview.widget.CardView
    android:id="@+id/card_view_questions"
    android:layout_width="240dp"
    android:layout_height="350dp"
    android:layout_below="@id/card_learning"
    android:layout_marginStart="16dp"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="10dp"
    android:layout_marginEnd="16dp"
    android:layout_marginBottom="40dp"
    app:cardCornerRadius="8dp"
    app:cardBackgroundColor="#51c6aa"
    app:cardElevation="4dp"
    app:cardUseCompatPadding="true">

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:padding="16dp"
        android:layout_marginTop="60dp">

<ImageView
            android:layout_width="96dp"
            android:layout_height="96dp"
            android:layout_gravity="center"
            android:id="@+id/imagecardsHelper" />

 <TextView
            android:id="@+id/text_card_front"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:text="@string/front_side"
            android:layout_marginTop="5dp"
            android:textColor="#FFFF"
            android:textSize="16sp"
            android:gravity="center"
            android:textAppearance="@style/TextAppearance.AppCompat.Title" />
        <TextView
            android:id="@+id/text_card_back"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:text="@string/back_side"
            android:visibility="invisible"
            android:layout_marginTop="5dp"
            android:textColor="#FFFF"
            android:textSize="16sp"
            android:gravity="center"
            android:textAppearance="@style/TextAppearance.AppCompat.Title" />
</LinearLayout>

I have set height and width of Textview to wrap_content sometimes and sometimes even max_parent so every Text content that is about get displayed is displayed properly and I even tried to set the measurements manually but still it's not showing complete content of every pharses


Solution

  • Issue is in android:layout_height="30dp" Replace 30dp to wrap_content