title: How to Auto resize the text in Textview in android when data/values invoke from the server
body: <p>Textview does not resize its size when data/values invoke from server, it appears in half of the screen and layout design looks bad.</p>
  <p><strong>Issue</strong></p>
  <p>When Data or in my case &quot;story&quot; comes from server it will display in the textview, For bigger story like above 100  words it looks fine but for smaller story i.e., 50 words or smaller. Then it looks bad. Layout design takes half of the screen as mentioned in the image.</p>
  <p><strong>Question</strong></p>
  <p>How to <strong>auto resize</strong> the text size according to bigger screens. Since I face this problem for bigger screens like Galaxy s20 Ultra where display size is 6.90 inch with 1440x3200 xxhdpi.
  <strong>Code</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;ScrollView
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;match_parent&quot;
      android:background=&quot;#FFFFFF&quot;&gt;
      &lt;androidx.constraintlayout.widget.ConstraintLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginTop=&quot;0dp&quot;
          android:background=&quot;#E6332049&quot;
          android:gravity=&quot;center&quot;
          android:orientation=&quot;vertical&quot;
          tools:context=&quot;.MainActivityActivity&quot;&gt;
          &lt;Button
              android:id=&quot;@+id/back_btn&quot;
              android:layout_width=&quot;50dp&quot;
              android:layout_height=&quot;50dp&quot;
              android:layout_marginTop=&quot;16dp&quot;
              android:background=&quot;@drawable/ic_back&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintHorizontal_bias=&quot;0.03&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
          &lt;RelativeLayout
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_alignParentStart=&quot;true&quot;
              android:layout_alignParentTop=&quot;true&quot;
              android:layout_marginTop=&quot;70dp&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;parent&quot;&gt;
              &lt;!-- frame_12  --&gt;
              &lt;RelativeLayout
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_alignParentStart=&quot;true&quot;
                  android:layout_alignParentTop=&quot;true&quot;
                  android:layout_alignParentEnd=&quot;true&quot;
                  android:layout_marginTop=&quot;85dp&quot;
  
                  android:background=&quot;@drawable/story_row&quot;&gt;
                  &lt;!--Summary, Story, connclusion and rating layout--&gt;
                  &lt;!--Summary start --&gt;
                  &lt;RelativeLayout
                      android:id=&quot;@+id/frame_3_summary&quot;
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:layout_alignParentTop=&quot;true&quot;
                      android:layout_centerHorizontal=&quot;true&quot;
                      android:layout_marginStart=&quot;30dp&quot;
                      android:layout_marginTop=&quot;15dp&quot;
                      android:background=&quot;@drawable/frame_3&quot;&gt;
                      &lt;RelativeLayout
                          android:layout_width=&quot;match_parent&quot;
                          android:layout_height=&quot;wrap_content&quot;
                          android:layout_alignParentStart=&quot;true&quot;
                          android:layout_alignParentTop=&quot;true&quot;
                          android:layout_marginStart=&quot;16dp&quot;
                          android:layout_marginTop=&quot;38dp&quot;
                          android:layout_marginEnd=&quot;16dp&quot;
                          android:layout_marginBottom=&quot;14dp&quot;&gt;
                          &lt;TextView
                              android:id=&quot;@+id/description&quot;
                              android:layout_width=&quot;match_parent&quot;
                              android:layout_height=&quot;wrap_content&quot;
                              android:layout_alignParentStart=&quot;true&quot;
                              android:layout_alignParentTop=&quot;true&quot;
                              android:fontFamily=&quot;sans-serif&quot;
                              android:gravity=&quot;top&quot;
                              android:lineSpacingExtra=&quot;3sp&quot;
                              android:text=&quot;Hello this is description part for testing purpose it wont appear when the app is in running mode&quot;
                              android:textColor=&quot;#FFFFFF &quot;
                              android:textSize=&quot;15sp&quot;
                              android:translationY=&quot;-1.58sp&quot;
                              app:autoSizeMinTextSize=&quot;12sp&quot;
                              app:autoSizeTextType=&quot;none&quot; /&gt;
                      &lt;/RelativeLayout&gt;
                      &lt;TextView
                          android:layout_width=&quot;343dp&quot;
                          android:layout_height=&quot;27dp&quot;
                          android:layout_alignParentStart=&quot;true&quot;
                          android:layout_alignParentTop=&quot;true&quot;
                          android:layout_marginStart=&quot;16dp&quot;
                          android:layout_marginTop=&quot;10dp&quot;
                          android:fontFamily=&quot;sans-serif&quot;
                          android:gravity=&quot;top&quot;
                          android:text=&quot;Summary&quot;
                          android:textColor=&quot;#FFFFFF&quot;
                          android:textSize=&quot;20sp&quot; /&gt;
                  &lt;/RelativeLayout&gt;
                  &lt;!-- Summary End--&gt;
                  &lt;!--Story start --&gt;
                  &lt;RelativeLayout
                      android:id=&quot;@+id/frame_5_story&quot;
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:layout_below=&quot;@+id/frame_3_summary&quot;
                      android:layout_centerHorizontal=&quot;true&quot;
                      android:layout_marginStart=&quot;30dp&quot;
                      android:layout_marginTop=&quot;15dp&quot;
                      android:background=&quot;@drawable/frame_5&quot;&gt;
                      &lt;RelativeLayout
                          android:layout_width=&quot;match_parent&quot;
                          android:layout_height=&quot;wrap_content&quot;
                          android:layout_alignParentStart=&quot;true&quot;
                          android:layout_alignParentTop=&quot;true&quot;
                          android:layout_marginStart=&quot;16dp&quot;
                          android:layout_marginTop=&quot;38dp&quot;
                          android:layout_marginEnd=&quot;17dp&quot;
                          android:layout_marginBottom=&quot;16dp&quot;&gt;
                          &lt;TextView
                              android:id=&quot;@+id/story&quot;
                              android:layout_width=&quot;match_parent&quot;
                              android:layout_height=&quot;wrap_content&quot;
                              android:layout_alignParentStart=&quot;true&quot;
                              android:layout_alignParentTop=&quot;true&quot;
                              android:layout_marginBottom=&quot;8dp&quot;
                              android:autoSizeStepGranularity=&quot;2sp&quot;
                              android:fontFamily=&quot;sans-serif&quot;
                              android:gravity=&quot;top&quot;
                              android:lineSpacingExtra=&quot;3sp&quot;
                              android:text=&quot;@string/story_detail&quot;
                              android:textColor=&quot;@color/white&quot;
                              android:textSize=&quot;15sp&quot;
                              android:translationY=&quot;-1.58sp&quot;
                              app:autoSizeMinTextSize=&quot;12sp&quot;
                              android:autoSizeMaxTextSize=&quot;50sp&quot;
                              app:autoSizeTextType=&quot;uniform&quot;
                              tools:targetApi=&quot;o&quot; /&gt;
                      &lt;/RelativeLayout&gt;
                      &lt;TextView
                          android:layout_width=&quot;311dp&quot;
                          android:layout_height=&quot;27dp&quot;
                          android:layout_alignParentStart=&quot;true&quot;
                          android:layout_alignParentTop=&quot;true&quot;
                          android:layout_marginStart=&quot;16dp&quot;
                          android:layout_marginTop=&quot;10dp&quot;
                          android:fontFamily=&quot;sans-serif&quot;
                          android:gravity=&quot;top&quot;
                          android:text=&quot;Story&quot;
                          android:textColor=&quot;#FFFFFF&quot;
                          android:textSize=&quot;20sp&quot; /&gt;
                  &lt;/RelativeLayout&gt;
                  &lt;!--Story end --&gt;
                  &lt;!--conclusion start --&gt;
                  &lt;RelativeLayout
                      android:id=&quot;@+id/frame_4_conclusion&quot;
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:layout_below=&quot;@+id/frame_5_story&quot;
                      android:layout_centerHorizontal=&quot;true&quot;
                      android:layout_marginStart=&quot;30dp&quot;
                      android:layout_marginTop=&quot;15dp&quot;
                      android:background=&quot;@drawable/frame_4&quot;&gt;
                      &lt;RelativeLayout
                          android:layout_width=&quot;match_parent&quot;
                          android:layout_height=&quot;wrap_content&quot;
                          android:layout_alignParentStart=&quot;true&quot;
                          android:layout_alignParentTop=&quot;true&quot;
                          android:layout_marginStart=&quot;16dp&quot;
                          android:layout_marginTop=&quot;38dp&quot;
                          android:layout_marginEnd=&quot;17dp&quot;
                          android:layout_marginBottom=&quot;14dp&quot;&gt;
                          &lt;TextView
                              android:id=&quot;@+id/conclusion&quot;
                              android:layout_width=&quot;match_parent&quot;
                              android:layout_height=&quot;match_parent&quot;
                              android:layout_alignParentStart=&quot;true&quot;
                              android:layout_alignParentTop=&quot;true&quot;
                              android:fontFamily=&quot;sans-serif&quot;
  
                              android:gravity=&quot;top&quot;
                              android:lineSpacingExtra=&quot;3sp&quot;
                              android:text=&quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis aliquet.&quot;
                              android:textColor=&quot;#F2F2F3&quot;
                              android:textSize=&quot;15sp&quot;
                              android:translationY=&quot;-1.58sp&quot;
                              app:lineHeight=&quot;24sp&quot; /&gt;
                      &lt;/RelativeLayout&gt;
                      &lt;TextView
  
                          android:layout_width=&quot;match_parent&quot;
                          android:layout_height=&quot;29dp&quot;
                          android:layout_alignParentStart=&quot;true&quot;
                          android:layout_alignParentTop=&quot;true&quot;
                          android:layout_marginStart=&quot;16dp&quot;
                          android:layout_marginTop=&quot;12dp&quot;
                          android:layout_marginEnd=&quot;16dp&quot;
                          android:fontFamily=&quot;sans-serif&quot;
                          android:gravity=&quot;top&quot;
                          android:text=&quot;Conclusion&quot;
                          android:textColor=&quot;#FFFFFF&quot;
                          android:textSize=&quot;20sp&quot;
                          app:lineHeight=&quot;27sp&quot; /&gt;
                  &lt;/RelativeLayout&gt;
                  &lt;!--conclusion end --&gt;
                  &lt;!--Rating bar start--&gt;
                  &lt;!-- Rating --&gt;
                  &lt;RelativeLayout
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;43dp&quot;
                      android:layout_below=&quot;@+id/frame_4_conclusion&quot;
                      android:layout_centerHorizontal=&quot;true&quot;
                      android:layout_marginStart=&quot;30dp&quot;
                      android:layout_marginTop=&quot;15dp&quot;
                      android:layout_marginBottom=&quot;9dp&quot;
                      android:background=&quot;@drawable/button&quot;&gt;
                      &lt;!-- Text --&gt;
                      &lt;LinearLayout
                          android:layout_width=&quot;match_parent&quot;
                          android:layout_height=&quot;30dp&quot;
                          android:layout_alignParentTop=&quot;true&quot;
                          android:layout_centerHorizontal=&quot;true&quot;
                          android:layout_marginTop=&quot;10dp&quot;
                          android:layout_marginEnd=&quot;35dp&quot;
                          android:layout_marginBottom=&quot;10dp&quot;
                          android:orientation=&quot;horizontal&quot;
                          android:weightSum=&quot;10&quot;
                          tools:ignore=&quot;UselessParent&quot;&gt;
                          &lt;TextView
                              android:layout_width=&quot;0dp&quot;
                              android:layout_height=&quot;18dp&quot;
                              android:layout_weight=&quot;10&quot;
                              android:fontFamily=&quot;sans-serif&quot;
                              android:lineHeight=&quot;18sp&quot;
                              android:text=&quot;Rate this story&quot;
                              android:textColor=&quot;#FFFFFF&quot;
                              android:textSize=&quot;14sp&quot;
  
                              tools:ignore=&quot;UnusedAttribute&quot; /&gt;
                          &lt;!-- stars --&gt;
                          &lt;RelativeLayout
                              android:layout_width=&quot;wrap_content&quot;
                              android:layout_height=&quot;wrap_content&quot;
                              android:layout_marginTop=&quot;2dp&quot;
  
  
                              &gt;
                              &lt;RatingBar
                                  android:id=&quot;@+id/ratingBar&quot;
                                  style=&quot;@style/MyRatingBar&quot;
                                  android:layout_width=&quot;wrap_content&quot;
                                  android:layout_height=&quot;28dp&quot;
                                  android:isIndicator=&quot;false&quot;
                                  android:numStars=&quot;5&quot;
                                  android:progressBackgroundTint=&quot;@color/white&quot;
                                  android:progressTint=&quot;#FDD835&quot;
                                  android:rating=&quot;0&quot;
                                  android:scaleX=&quot;1&quot;
                                  android:scaleY=&quot;1&quot;
                                  android:secondaryProgressTint=&quot;@android:color/white&quot;
                                  android:stepSize=&quot;0.5&quot;
                                  tools:ignore=&quot;UnusedAttribute&quot; /&gt;
                          &lt;/RelativeLayout&gt;
                      &lt;/LinearLayout&gt;
                  &lt;/RelativeLayout&gt;
                  &lt;!--Rating bar end--&gt;
              &lt;/RelativeLayout&gt;
              &lt;!-- Header layout start   --&gt;
              &lt;RelativeLayout
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;74dp&quot;
                  android:layout_alignParentStart=&quot;true&quot;
                  android:layout_alignParentTop=&quot;true&quot;
                  android:layout_marginStart=&quot;16dp&quot;&gt;
                  &lt;RelativeLayout
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;74dp&quot;
                      android:layout_alignParentTop=&quot;true&quot;
                      tools:ignore=&quot;UselessParent&quot;&gt;
                      &lt;RelativeLayout
                          android:layout_width=&quot;match_parent&quot;
                          android:layout_height=&quot;74dp&quot;
                          android:layout_alignParentTop=&quot;true&quot;
                          android:layout_centerHorizontal=&quot;true&quot;&gt;
                          &lt;RelativeLayout
                              android:layout_width=&quot;102dp&quot;
                              android:layout_height=&quot;18dp&quot;
                              android:layout_alignParentStart=&quot;true&quot;
                              android:layout_alignParentTop=&quot;true&quot;
                              android:layout_marginTop=&quot;52dp&quot;&gt;
                              &lt;RelativeLayout
                                  android:layout_width=&quot;45dp&quot;
                                  android:layout_height=&quot;18dp&quot;
                                  android:layout_alignParentStart=&quot;true&quot;
                                  android:layout_alignParentTop=&quot;true&quot;
                                  android:layout_marginStart=&quot;50dp&quot;&gt;
                                  &lt;TextView
                                      android:id=&quot;@+id/views&quot;
                                      android:layout_width=&quot;25dp&quot;
                                      android:layout_height=&quot;18dp&quot;
                                      android:layout_alignParentStart=&quot;true&quot;
                                      android:layout_alignParentTop=&quot;true&quot;
                                      android:layout_marginStart=&quot;17dp&quot;
                                      android:gravity=&quot;top&quot;
                                      android:text=&quot;556&quot;
                                      android:textColor=&quot;#FFFFFF &quot;
                                      android:textSize=&quot;13sp&quot; /&gt;
                                  &lt;ImageView
                                      android:layout_width=&quot;wrap_content&quot;
                                      android:layout_height=&quot;wrap_content&quot;
                                      android:layout_marginTop=&quot;4dp&quot;
                                      android:background=&quot;@drawable/ic_show&quot;
                                      android:contentDescription=&quot;eye&quot; /&gt;
                              &lt;/RelativeLayout&gt;
                              &lt;RelativeLayout
                                  android:layout_width=&quot;41dp&quot;
                                  android:layout_height=&quot;18dp&quot;
                                  android:layout_alignParentStart=&quot;true&quot;
                                  android:layout_alignParentTop=&quot;true&quot;&gt;
                                  &lt;TextView
                                      android:id=&quot;@+id/rating&quot;
                                      android:layout_width=&quot;21dp&quot;
                                      android:layout_height=&quot;18dp&quot;
                                      android:layout_alignParentStart=&quot;true&quot;
                                      android:layout_alignParentTop=&quot;true&quot;
                                      android:layout_marginStart=&quot;17dp&quot;
                                      android:gravity=&quot;top&quot;
                                      android:text=&quot;4.5&quot;
                                      android:textColor=&quot;#FFFFFF&quot;
                                      android:textSize=&quot;13sp&quot; /&gt;
                                  &lt;ImageView
                                      android:layout_width=&quot;wrap_content&quot;
                                      android:layout_height=&quot;wrap_content&quot;
                                      android:layout_marginTop=&quot;2.67dp&quot;
                                      android:layout_marginBottom=&quot;2.67dp&quot;
                                      android:background=&quot;@drawable/staar&quot;
                                      android:contentDescription=&quot;star&quot; /&gt;
                              &lt;/RelativeLayout&gt;
                          &lt;/RelativeLayout&gt;
                          &lt;TextView
                              android:layout_width=&quot;wrap_content&quot;
                              android:layout_height=&quot;16dp&quot;
                              android:layout_marginTop=&quot;30dp&quot;
                              android:gravity=&quot;top&quot;
                              android:text=&quot;By&quot;
                              android:textColor=&quot;#F2F2F3&quot;
                              android:textSize=&quot;12sp&quot;
  
                              /&gt;
                          &lt;TextView
                              android:id=&quot;@+id/authorName&quot;
                              android:layout_width=&quot;wrap_content&quot;
                              android:layout_height=&quot;16dp&quot;
                              android:layout_alignParentStart=&quot;true&quot;
                              android:layout_alignParentTop=&quot;true&quot;
                              android:layout_marginStart=&quot;15dp&quot;
                              android:layout_marginTop=&quot;30dp&quot;
                              android:fontFamily=&quot;sans-serif&quot;
                              android:gravity=&quot;top&quot;
                              android:text=&quot;Author name&quot;
                              android:textColor=&quot;#F2F2F3&quot;
                              android:textSize=&quot;12sp&quot; /&gt;
                          &lt;TextView
                              android:id=&quot;@+id/header&quot;
                              android:layout_width=&quot;wrap_content&quot;
                              android:layout_height=&quot;36dp&quot;
                              android:layout_alignParentStart=&quot;true&quot;
                              android:layout_alignParentTop=&quot;true&quot;
                              android:fontFamily=&quot;sans-serif&quot;
                              android:gravity=&quot;top&quot;
                              android:lineSpacingExtra=&quot;0sp&quot;
                              android:text=&quot;Three Bears&quot;
                              android:textColor=&quot;@color/white&quot;
                              android:textSize=&quot;22sp&quot; /&gt;
                      &lt;/RelativeLayout&gt;
                  &lt;/RelativeLayout&gt;
              &lt;/RelativeLayout&gt;
          &lt;/RelativeLayout&gt;
      &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  &lt;/ScrollView&gt;
  
  
  </code></pre>
  <p>Do I need to create separate layout files for xxhdpi, xxxhdpi &amp; tablets? If yes then will my app size increase? Because I want my app size smaller then 5MB not more.</p>
  <p><strong>Image</strong>
  <a href="https://i.stack.imgur.com/x58vM.png" rel="nofollow noreferrer">Image</a></p>