简体   繁体   中英

Android - How to force spinner dropdown to open right-aligned

On an app that I am working on, I have a small spinner on the right hand side of the screen.

The problem is that on some devices the spinner dropdown opens right-aligned, while on others the spinner dropdown opens left-aligned, with the text coming off the screen.

I would like to know, is there a way to force the spinner dropdown to open right-aligned on all devices to prevent the text from coming off the screen?

EDIT: Here is the XML for the Spinner:

<Spinner
    android:layout_width="120dp"
    android:layout_height="wrap_content"
    android:id="@+id/reportList"
    android:layout_alignParentTop="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_marginTop="25dp"/>

For resizing the Spinner's window this solution was propposed in a different question.

The question was asked in Spanish but see the answer of Jorgesys that uses reflection. Perhaps it puts you on the right path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM