Activity as dialog using HoloEverywhere cuts off layout

≡放荡痞女 提交于 2020-01-03 05:45:20

问题


I'm using the HoloEverywhere library in my Android app to ensure a consistent theme across all supported devices. However, I'm running into trouble with activities that utilize Holo.Theme.Dialog: on my Android 2.2 emulator it displays correctly, but on my Android 4 device (which has the actual Holo theme available) the layout cuts off items on the right edge of the dialog.

My question is, how can I force devices that have the stock Holo theme to use that instead of HoleEverywhere? Or, how can I modify HoloEverywhere to make activities styled as dialogs display correctly on Android 4+ devices?

Screenshots:

Dialog in Android 4+

Dialog in Android 2.2


回答1:


I'm not sure if this bug has been fixed in HoloEverywhere or not, but my solution was to change all of my dialog activity classes to AlertDialogs. This required some code changes, but now I can be sure my dialogs will look and act as expected.




回答2:


Here's what you need to do:

  1. In your values folder, create a style in styles.xml file referencing Holo.Theme as a parent. In my case, I used AppBaseTheme

    <style name="AppBaseTheme" parent="Holo.Theme.Light"></style>
    
  2. In your manifest, make sure that you are referencing this style in your activities and in your application tag.

    <application
      ...
      android:theme="@style/AppBaseTheme" >
    
  3. Create a folder in your res folder named values-11 (if there isn't one already)

  4. Create another styles.xml file.

  5. Copy the same style you placed earlier in values folder, but reference the built in Holo theme included in 4.0

    <style name="AppBaseTheme" parent="android:Theme.Holo.Light"></style>
    


来源:https://stackoverflow.com/questions/15623965/activity-as-dialog-using-holoeverywhere-cuts-off-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!