Kann jemand bitte ein Beispiel, wie zu verwenden this Klasse? Ich benutze es direkt in meinem XML und habe nicht funktioniert.Android auto resize Text funktioniert nicht
<LinearLayout
android:id="@+id/button_30_days_plan"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_gravity="center"
android:layout_marginBottom="20dp"
android:background="@color/primary"
android:padding="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0"
android:maxLines="1"
android:text="@string/monthly_plan_title"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/white" />
<mycompany.mobile.core.ui.AutoResizeTextView
android:id="@+id/price_30_days_plan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:maxLines="1"
android:layout_gravity="center_vertical"
android:text="@string/monthly_plan_cost"
android:textColor="@color/white"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
Die AutoResizeTextView sollte die verbleibende Breite Linearlayout verwenden und die Größe, wenn die Breite ist nicht genug. In einem anderen Teil des Codes scheint es perfekt zu funktionieren, und es verweist nur auf die ID im Java-Code, ohne etwas in Bezug auf die AutoResizeTextView-Klasse zu setzen.
<-- This is works -->
<LinearLayout
android:id="@+id/layout_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/StartIcon"
android:layout_alignTop="@+id/StartIcon"
android:layout_toLeftOf="@+id/ReverseButton"
android:gravity="center_vertical"
android:layout_toRightOf="@+id/StartIcon"
android:orientation="vertical">
<mycompany.mobile.core.ui.AutoResizeTextView
android:id="@+id/StartLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:maxLines="1"
android:text="@string/direction_click_here_label"
android:textColor="#001485"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/TapToChangeStartLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tap to change destination"
android:textColor="#001485"
android:layout_marginTop="-3dp"
android:visibility="gone"
android:textSize="12sp" />
</LinearLayout>
Ich versuchte Anruf setMinTextSize() und setMaxTextSize() nach der Textlänge prüfen und arbeiten immer noch nicht. Irgendwelche Hilfe bitte.