我有一个自然有多行的微调器。对于每一行,我需要两行,每行不同的字体。我该怎么做?
例如,假装这些行有不同的字体
LINE ONE OF FONT 1
line two of font 2
最佳答案
创建一个扩展 ArrayAdapter
的适配器并覆盖 getDropDownView()
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
View view;
if (convertView == null) {
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.spinner_location_item, parent, false);
} else {
view = convertView;
}
TextView textView1 = (TextView) view.findViewById(R.id.your_first_view);
TextView textView2 = (TextView) view.findViewById(R.id.your_second_view);
textView1.setText("LINE 1");
textView2.setText("LINE 2");
return view;
}
然后你可以给它任何你想要的布局。
关于android - 使用两行不同的字体创建微调器下拉菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38364033/