Spinner Text不会换行

时间:2015-01-06 11:29:23

标签: android android-spinner

我正在开发Android应用程序,其中我使用了微调视图但旋转器上的文本没有包装所以请帮助我如何实现这一点。

提前致谢enter image description here

 ArrayAdapter<String> adapter_state1 = new ArrayAdapter<String>(
                getActivity(), android.R.layout.simple_spinner_item,
                scondDD_ItemName) {

            public View getView(int position, View convertView, ViewGroup parent) {
                View v = super.getView(position, convertView, parent);

                Typeface externalFont = Typeface.createFromAsset(getActivity()
                        .getAssets(), "fonts/Roboto-Regular.ttf");
                ((TextView) v).setTypeface(externalFont);
                return v;
            }

            public View getDropDownView(int position, View convertView,
                    ViewGroup parent) {
                View v = super.getDropDownView(position, convertView, parent);

                Typeface externalFont = Typeface.createFromAsset(getActivity()
                        .getAssets(), "fonts/Roboto-Regular.ttf");
                ((TextView) v).setTypeface(externalFont);

                return v;
            }
        };

        adapter_state1
                .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner2.setAdapter(adapter_state1);

1 个答案:

答案 0 :(得分:1)

您可以使用根元素TextView创建布局并使用android:singleLine="false"。然后使用此布局而不是android.R.layout.simple_spinner_item_1