在中心组查看文本对齐微调的机器人 [英] set view text align at center in spinner in android
本文介绍了在中心组查看文本对齐微调的机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复,在微调时,从下拉列表中选择中心查看文本
possible duplicate with view text in the center of the spinner when select from the drop down list
我要对齐微调,以中心查看文本。我谷歌,但没有发现任何东西,不会有人知道这事吗?任何帮助或建议的AP preciated
I want to align the view text of spinner to center. I google it but didn't find anything, does anybody knows about this? any help or suggestion are appreciated
感谢
推荐答案
您的微调像这样创建一个适配器,
Create a adapter for your spinner like this,
ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, R.layout.my_spinner_style,array_of_values) {
public View getView(int position, View convertView,ViewGroup parent) {
View v = super.getView(position, convertView, parent);
((TextView) v).setTextSize(16);
return v;
}
public View getDropDownView(int position, View convertView,ViewGroup parent) {
View v = super.getDropDownView(position, convertView,parent);
((TextView) v).setGravity(Gravity.CENTER);
return v;
}
};
现在布局的 R.layout.my_spinner_style
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+android:id/text1"
style="?android:attr/spinnerItemStyle"
android:singleLine="true"
android:textColor="#ffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee" />
现在设置该适配器将微调,
Now set this adapter to your spinner,
spinner.setAdapter(adapter);
这篇关于在中心组查看文本对齐微调的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文