Android : AccountPicker set Light Theme

会有一股神秘感。 提交于 2019-12-09 15:59:20

问题


Is it possible to set the theme of picker dialog ?

import com.google.android.gms.common.AccountPicker;
....
String[] accountTypes = new String[]{"com.google"};
Intent intent = AccountPicker.newChooseAccountIntent(null, null,
                accountTypes, false, null, null, null, null);
activity.startActivityForResult(intent, REQUEST_CODE_PICK_ACCOUNT);

My base app theme is android:Theme.Light but that dialog is dark. Thanks.


回答1:


If you wish to change the theme of the dialog, you should change the newChooseAccountIntent to zza and add two integer arguments. The first one is for overriding the theme and setting it to 1 will change the dialog theme to light.

String[] accountTypes = new String[]{"com.google"};
Intent intent = AccountPicker.zza(null, null, accountTypes, false, null, null, null, null, false, 1, 0);
startActivityForResult(intent, REQUEST_CODE_PICK_ACCOUNT);



回答2:


you can change it when you overwrite over any args are defined in a parent class in method newChooseAccountIntent(Account var0, ArrayList<Account> var1, String[] var2, boolean var3, String var4, String var5, String[] var6, Bundle var7) {}

it is very simple to change it by adding it to your code...

Intent intent = AccountPicker.newChooseAccountIntent(null, null, new String[]{GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE}, false, null, null, null, null). putExtra("overrideTheme", 1); startActivityForResult(intent, REQUEST_CODE_EMAIL);

1 means the Light Theme

0 means the Dark Theme



来源:https://stackoverflow.com/questions/22047940/android-accountpicker-set-light-theme

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