问题
I am working on android app where I am thinking to develop reusable UI interface. How it can be developed and included in my .xml's
Here I want to develop a progress bar with my image and it will be display on some .xml's. Please provide any code help.
I am a new in this field.
回答1:
you can use <Include> xml tag within your layout xml,
read this :) http://developer.android.com/resources/articles/layout-tricks-merge.html
回答2:
I think you need to use styles and themes. Check this out.
回答3:
You can either build custom (compound) views, look at Building Custom Components.
Or you can use Fragments. Fragments are new in Honeycomb (Android 3.0), but there is a compatibility library that adds fragment support to lower android versions (can be found in your ANDROID_SDK/extras/android folder). Or you can mix both of course.
来源:https://stackoverflow.com/questions/7106625/reusable-ui-in-android-app