0

I've got a handful of configuration dialogs in my app, and they all have Cancel/OK buttons at the bottom. Now, in API level 11 and up, I want to show Cancel on the left and OK on the right, and also use the ButtonBar style. In API levels 10 and lower I want to show floating buttons, with OK on the left.

Presently I have copies of the XML layouts in both my layout and my layout-v11 folder, with nothing different between them but the button area. However these layouts are fairly complex and I'm trying to save some space, so it would really be better to just have one copy of each layout, and just snap the layouts into a template with the correct button style on the bottom. What would be the best way to go about this? Fragments?

4

1 回答 1

1

Why not do just the button swap programatically? You can find the build version codes from SDK_INT and swap the PositiveButton and NegativeButton based on the SDK versions.

If you have the layouts in the xml files and cannot be done in the code for some reasons, you have just the buttons in two different layouts and use the merge tag

于 2013-09-19T22:56:07.780 回答