android spanner下拉列表内容居中

这是我的spinner XML文件,它不起作用:

1
2
3
4
5
6
7
< Spinner
       android:id = "@+id/frequency"
       android:layout_width = "wrap_content"
       android:layout_height = "wrap_content"
       android:background = "@drawable/spinner_voices"
       android:gravity = "center|center_horizontal"
        />


解决方法 1:

你需要设置你自己的spinner布局

1
2
ArrayAdapter adap = new ArrayAdapter( this , R.layout.spinner_item, new String[]{ "ABC" , "DEF" , "GHI" });
spriner.setAdapter(adap);
1
2
3
4
5
xml version = "1.0" encoding = "utf-8" ?>
< TextView xmlns:android = "http://schemas.android.com/apk/res/android"
     android:layout_height = "fill_parent"
     android:layout_width = "fill_parent"
     android:gravity = "center" />

你可能感兴趣的:(android)