xml of spinner
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_length"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:background="@drawable/bg_textview_sky_bolor"
android:paddingStart="@dimen/dp_5"
android:paddingTop="@dimen/dp_5"
android:paddingBottom="@dimen/dp_5"
android:paddingEnd="@dimen/dp_5"
android:maxLines="1"
android:text="length"
android:textSize="@dimen/sp_12"
android:textAllCaps="true"
android:textColor="@color/colorBlack"
android:gravity="center"
/>
<Spinner
android:id="@+id/sp_length"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:background="@color/colorWhite"
android:maxLines="1"
android:textColor="@color/colorBlack"
android:gravity="center"
android:spinnerMode="dropdown"
android:visibility="visible"
/>
</LinearLayout>
JAVA Code
private String[] spinnerItemsAmp={"5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","45","46","47","48","49","50"};
binding.spLength.setAdapter(new ArrayAdapter<>(context, R.layout.spinner_length_layout,spinnerItemsAmp));
binding.spLength.setSelection(0,false);
binding.spLength.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, final View view, final int position, long id) {
mLength=binding.spLength.getItemAtPosition(position).toString();
}
Here spinner open but it take whole the screen i want to decrease the height of spinner means it display in half screen