PhoneGap & Android - How to use the new select list style

后端 未结 4 960
失恋的感觉
失恋的感觉 2021-01-14 13:37

I developed an mobile app for Android using PhoneGap. I also published it for browsers.

On my phone, when I view the app in Chrome, I get the following select menu s

相关标签:
4条回答
  • 2021-01-14 14:05

    You can't but more important you should not!

    Each mobile platform has its own design principles which are designed to keep best user's interest in mind. For iOS it could even mean that your app will be rejected.

    Even different android builds tend to have different ui principles like in your pictures where the first one shows the select menu from original android and the last shows the select menu from samsungs android.

    So you can't style the select menu using css. However you could write a phonegap plugin to give you a custom select menu.

    Another option would be to build a select menu without html's select but just javascript. But I would not suggest that.

    0 讨论(0)
  • 2021-01-14 14:07

    I had a similar issue with my dialogs in my Phonegap app in Android. The default theme in a cordova android app is:

    android:theme="@android:style/Theme.Black.NoTitleBar"
    

    Take a look to your AndroidManifest.xml, in your MAIN activity. If this is the case change it to

    android:theme="@android:style/Theme.Holo.Light.NoActionBar"
    

    Chrome seems to use this theme according your screenshot (or a similar).

    0 讨论(0)
  • 2021-01-14 14:12

    Each browser displays elements in its specific way. You should use -webkit-appearence to try to reset the select to its default appearence:

    select {
        -webkit-appearance: none;
        -moz-appearance:    none;
        appearance:         none;
    }
    
    0 讨论(0)
  • 2021-01-14 14:15

    There is no way to style that using css only. That is not a html component, it's not part of the DOM. Both the selectors you see are added on top of your browser by native methods.

    Essentially, if you want to change the default behavior of the select you must build your own select dialog and trigger it when the user clicks on a select.

    Check this similar question.

    0 讨论(0)
提交回复
热议问题