I created a drawable for my spinner background. It should draw a border and put an arrow to the right side of the spinner. It works perfectly with API 21+ devices as you see below ;
But it doesn't work as i expected with API 21 and below devices. Here how spinner looks like API 21;
My spinner code;
val requesterSpinner = Spinner(context)
requesterSpinner.id = Spinner.generateViewId()
val requesterSpinnerParams = LayoutParams(300, LayoutParams.WRAP_CONTENT)
requesterSpinner.background = context.getDrawable(R.drawable.spinner_background)
requesterSpinner.layoutParams = requesterSpinnerParams
My drawable codes;
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<layer-list>
<item>
<shape>
<solid
android:color="@color/white">
</solid>
<corners android:radius="3dp" />
<stroke
android:width="1dp"
android:color="#4d4d4d"/>
</shape>
</item>
<item android:drawable="@drawable/ic_baseline_arrow_drop_down_24"
android:gravity="right"
android:width="30dp">
</item>
</layer-list>
</item>
</selector>
And i saw something like android:width is not working for API'S below 23. I am okay with that but as you see the gravity attribute is not working as well.
How can i align arrow image to the right below API 23 ?