问题
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:
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>
In your manifest, make sure that you are referencing this style in your activities and in your application tag.
<application ... android:theme="@style/AppBaseTheme" >
Create a folder in your res folder named values-11 (if there isn't one already)
Create another styles.xml file.
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