更改微调的文字大小 [英] Changing the text size of a spinner
问题描述
我在Android的编程初学者。
I am a beginner in Android programming.
我想在某些问题中提及改变微调的文字大小的这里。我创建 my_spinner_style.xml
在 RES /价值/
如下:
I am trying to change the text size of the spinner as mentioned in some question here. I have created my_spinner_style.xml
in res/values/
as below:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/spinnerTarget"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="13sp"
/>
和使用这样的适配器:
spinner = (Spinner)findViewById(R.id.spinner);
ArrayAdapter<CharSequence> adapter=ArrayAdapter.createFromResource(this,R.array.answers,android.R.layout.my_spinner_style);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(this);
和还试图在布局文件夹内创建 style.xml
。我的适配器无法识别 my_spinner_style
。我已经把它在错误的目录?
and also tried creating style.xml
in the layout folder. My adapter does not recognize my_spinner_style
. Have I placed it in the wrong directory?
推荐答案
这应该是 R.layout.my_spinner_style
,删除 安卓
在一开始,这使得它指向Android包,而不是你的项目。
It should be R.layout.my_spinner_style
, remove the android
at the start, that makes it point to the Android package and not your project.
请注意要导入的R是项目的资源,说android.R点到Android资源,而不是你的项目。
Note the R you're importing is your project's Resources, saying android.R points to Android resources, not your project.
//编辑这是根据屏幕大小如何有大小
dimens.xml 这是下的值(默认):
dimens.xml This is under values (default):
<resources>
<!-- Font sizes in SP -->
<dimen name="small_font">14sp</dimen>
<dimen name="big_font">20sp</dimen>
</resources>
dimens.xml 这是在我的价值观-FR(法语,你的情况,你就会有屏幕尺寸预选赛)
dimens.xml this is under my values-fr (French, in your case, you'll have screen size qualifiers)
<resources>
<!-- Font sizes in SP -->
<dimen name="small_font">16sp</dimen>
<dimen name="big_font">22sp</dimen>
</resources>
然后在我的的TextView
为例,这是我的字体大小:
Then in my TextView
for example, this is my font size:
<TextView
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/small_font">
</TextView>
现在的字体大小取决于语言(英语去为 值
和法国去的 值-FR
)你应该有同样的事情,但使用的屏幕尺寸限定词。
Now the font size is dependent on the language (English goes to values
and French goes to values-fr
) You should have the same thing but using screen size qualifiers.
这篇关于更改微调的文字大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!