我有一个文本视图,里面有许多布局。
此视图是
RecyclerView
,并且texxt在
Adapter
.
有时文字太大,会被剪掉。因此,我想在Api 26中使用自动调整大小功能。然而,即使我更新了支持库并放入了xml属性,它也不起作用。
这是我的代码:
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
android:id="@+id/zmanCard"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
cardview:cardUseCompatPadding="false"
cardview:cardPreventCornerOverlap="false"
cardview:cardCornerRadius="4dp"
cardview:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorPrimary"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_gravity="top"
android:orientation="vertical"
android:background="?attr/colorPrimaryDark">
<!-- The AutoResizeTextView -->
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="20dp"
android:id="@+id/zmanCardTitle"
android:textColor="#ffffff"
cardview:autoSizeTextType="uniform"
cardview:autoSizeMaxTextSize="13sp"
cardview:autoSizeMinTextSize="5sp"
cardview:autoSizeStepGranularity="1sp"
android:gravity="center"
android:singleLine="true"
android:ellipsize="none"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="24dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:layout_marginTop="2dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:alpha="0.8"
android:id="@+id/zmanCardImage" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="7dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="2dp">
<TextView
android:text="5:40"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:id="@+id/zmanCardTime"
android:textColor="#ffffff"
android:ellipsize="none"
android:textSize="18sp"
android:singleLine="true"/>
<ProgressBar
android:id="@+id/zmanProgressBar"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
style="@style/Base.Widget.AppCompat.ProgressBar" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>