I want to count the total number of characters a TextView can hold with 14dp text size and 100dp of width and with 100dp of height. then I have to add those characters' limits to an EditText.
<TextView
android:id="@+id/OFSO_text1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_weight="1"
android:layout_gravity="top|center"
android:fontFamily="@font/lato_bold"
android:gravity="center|bottom"
android:text="SEASONAL DISCOUNT ARE HERE"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="@color/lightcream"
android:textSize="14dp"
android:textStyle="normal"
android:autoSizeTextType="none"
/>
I have tried this code but this is not working properly. this provides me more char limit then this Textview can holds.
TextPaint paint = textView.getPaint();
int wordwidth=(int)paint.measureText("a",0,1);
int screenwidth = getResources().getDisplayMetrics().widthPixels;
int maxLength = screenwidth/wordwidth;
please help me out!! thanks in advance. happy coding!!!