My goal is to create Auto rotate textView.Here is my xml code
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:id="@+id/u_major_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="@dimen/u_common_margin_left"
android:maxLines="1"
android:paddingRight="@dimen/u_common_margin_left"
android:singleLine="true"
android:text="0.00"
android:autoSizeTextType="uniform"
android:autoSizeMinTextSize="12dp"
android:autoSizeMaxTextSize="70dp"
android:autoSizeStepGranularity="2dp"
android:textColor="#000000"
android:textSize="70dp"
/>
<TextView
android:id="@+id/u_minor_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/u_major_text"
android:layout_marginLeft="-12dp"
android:layout_marginTop="7dp"
android:layout_toEndOf="@+id/u_major_text"
android:layout_toRightOf="@+id/u_major_text"
android:gravity="center"
android:singleLine="true"
android:text="₾"
android:textColor="#000000"
android:textSize="30dp" />
</RelativeLayout>
my goal is to my minor_textview can to be auto resize function.first time text size is 70dp but I want to decrease size depends on a text. What am I doing wrong ?
Apparently, since Android 8.0 and below (thanks to the Support Library) you can use an attribute to auto resize your Textview:
TextView minorText = findViewById(R.id.u_minor_text);
TextViewCompat.setAutoSizeTextTypeWithDefaults(text, TextViewCompat.AUTO_SIZE_TEXT_TYPE_UNIFORM);
Check this link: https://developer.android.com/guide/topics/ui/look-and-feel/autosizing-textview
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.