开发者

Setting a theme/style when using startActivity()

Simple question:

I am using PICK_CONTACT in my Android 3.0 application. The issue is that the contact app has a light theme while my app uses a dark one.

So the question is:

Is there a way to set a style/theme when using startActivity()?

If I am creating my own library and I want the user to be able to use customize styles, I will need to receive some开发者_开发知识库thing in the intent? Is there a better way to solve this?


Is there a way to set a style/theme when using startActivity()?

No. You have no right to mess with other apps' user interfaces, any more than they have a right to mess with yours.

In the case of PICK_CONTACT, if you are willing to have the READ_CONTACTS permission, there is nothing stopping you from writing your own contact picker activity, themed as you wish.

If I am creating my own library and I want the user to be able to use customize styles, I will need to receive something in the intent?

Since there is no setStyle() method, dynamically changing an activity's style seems troublesome.

If your library will be shipped as an Android library project, you can provide theme resources and guidance for developers who, when adding your activities to their manifest, can choose which theme to use at compile time.


No.

In general there is no standard method of specifying the theme/style an Activity should launch with: your idea (putting something in the Intent) would actually be an excellent way of doing it, but once again it isn't standard.

Wandering through the standard Contacts app source (https://android.googlesource.com/platform/packages/apps/Contacts ) there is no way to specify the theme in any of the Activity classes that PICK_CONTACT would invoke.

Your best bet would be to build a custom Contact picker and use the content provider. You'd need to ask for permissions and it would be a bit messier but that appears to be the only way to get what you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜