How to rotate popup with Android spinners
I am trying to achieve vertical Spinner
. I can rotate the view with
spinner.setRotation(-90);
But this only rotates the spinner view, not the dropdown. As shown in the picture below. How do I rotate the popup also?
After trying below answer I am getting into this problem
+3
user3270537
source
to share
1 answer
You will need to create a custom adapter for your meter.
Next on your getView, make sure you rotate the parent that is receiving it.
Adapter example:
public class AdapterTest extends ArrayAdapter<String> {
public AdapterTest(Context context, int resource, List<String> objects) {
super(context, resource, objects);
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
return getView(position, convertView, parent);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = LayoutInflater.from(getContext()).inflate(R.layout.row_spinner, parent, false);
if (parent.getRotation() == 0 && parent instanceof ListView) {
parent.setRotation(-90);
}
return v;
}
}
Result:
+1
source to share