Android 使用字符串数组中的数据设置xtsize
我正在尝试使用来自preferences活动的数据设置TextView的大小,该活动使用ListPreference,并且有三个选项。以下是res.xml文件夹中的ListPreference prefs.xml:Android 使用字符串数组中的数据设置xtsize,android,xml,Android,Xml,我正在尝试使用来自preferences活动的数据设置TextView的大小,该活动使用ListPreference,并且有三个选项。以下是res.xml文件夹中的ListPreference prefs.xml: <ListPreference android:title="Text Size" android:key="textsize" android:summary="Let you choose text size" android:en
<ListPreference
android:title="Text Size"
android:key="textsize"
android:summary="Let you choose text size"
android:entries="@array/textsize"
android:entryValues="@array/textSize" />
您可以使用以下内容:
<dimen name="test">16sp</dimen>
16sp
在您的TextView标记中:
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/long_string"
android:textSize="@dimen/test" />
TextView tV=(TextView) findViewById(R.id.textView1);
tV.setText(R.array.textSize);
<dimen name="test">16sp</dimen>
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/long_string"
android:textSize="@dimen/test" />