Is it possible to use a custom background for the FirebaseUI.AuthMethodPicker ONLY?
I know you can use <item name="android:windowBackground">#drawable/my_background</item> in the firebase ui theme, but this changes the background for all activities (e.g. register email, etc.), and thats not what I want.
Thank you already!
You can customize them in the theme with your own style (for firebase UI version 0.6.0 and above) where the theme parent are:-
FirebaseUI.AuthMethodPicker.Logo ,
FirebaseUI.AuthMethodPicker etc.
OR refer to nice github link :-
https://github.com/firebase/FirebaseUI-Android/tree/master/auth
This helped me change the ui of the screens that follow the sign in screen
<style name="FirebaseUI.WrapperStyle">
<item name="android:background">#mipmap/bg_login_flow</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_width">match_parent</item>
<item name="android:paddingTop">16dp</item>
<item name="android:paddingLeft">
#dimen/fui_wrapper_padding_horiz
</item>
<item name="android:paddingRight">#dimen/fui_wrapper_padding_horiz
</item>
</style>
The thing that allowed me to change only the AuthMethodPicker activity background was to override the whole layout resource file. In essence, you need to copy the fui_auth_method_picker_layout.xml from the FirebaseAuthUI github repository and set the background in there. The change there will not result in any of the other activities.
Related
I've followed Migrate your splash screen implementation, and it promises that After you migrate using the SplashScreen compat library, the system displays the same splash screen on all versions of Android.
I've created the new splash theme, but the issue is that, I don't have an option to put windowSplashScreenBrandingImage for style belowe values-v31, that is, for android lower than 12.
So the bottom bar that we have been using previously can'be shown as of now.
values-v31/style
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.App.SplashThemeNew" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">#android:color/white</item>
<item name="windowSplashScreenAnimatedIcon">#drawable/splash_icon</item>
<item name="android:windowSplashScreenBrandingImage">
#drawable/background_splash_12_bottom_strp
</item>
<item name="postSplashScreenTheme">#style/AppTheme</item>
</style>
</resources>
style
<style name="Theme.App.SplashThemeNew" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">#color/white</item>
<item name="windowSplashScreenAnimatedIcon">#drawable/splash_icon</item>
<item name="postSplashScreenTheme">#style/AppTheme</item>
</style>
While according to the Migration guide, it should be possible, Has anyone some ideas about this?
Thanks for your time and attention.
Unfortunately it is not possible to use the android:windowSplashScreenBrandingImage on api lower than 31. This issue has officially been reported as a feature request on the IssueTracker, but for now they say that it won't be implemented (Source). However, it is still assigned so it might get implemented in the future.
Besides that, the Android docs state that The design guidelines recommend against using a branding image.
That being said, I found an Medium article that might help you achieve what you are looking for.
I'm currently implementing Stripe into my application.
And using the example code from their documentation, I'm starting their PaymentMethodsActivity like this.
private fun startPaymentSelectActivity() {
val intent = PaymentMethodsActivity.newIntent(this#PaymentActivity)
startActivityForResult(intent, REQUEST_CODE_SELECT_SOURCE)
}
However, the created PaymentMethodsActivity's theme does not follow my app's theme, it's using their blue Toolbar. Like this
How do I apply a Theme to this Activity?
ScreenShot attached here
1.Download Stripe from here
"https://github.com/stripe/stripe-android"
2.import stripe module in your project and Update UI as you want from it's res folder
You can add this into your styles.xml and customize the colors
<style name="StripeDefaultTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#0091ea</item>
<item name="colorAccent">#color/accent_color_default</item>
<item name="colorControlNormal">#color/control_normal_color_default</item>
<item name="titleTextColor">#android:color/white</item>
<item name="android:textColorSecondary">#android:color/secondary_text_light</item>
</style>
Be careful to keep the style name ( name="StripeDefaultTheme" )
I'm using 'com.stripe:stripe-android:6.1.2' and that's work fine.
Source: https://github.com/stripe/stripe-android/issues/414
I've got an app with two themes (dark and light) that can be selected at runtime. This works. I also have a ListView with rows that can have one of three different layouts, each of which has a style (say, different colors). This also works. But I can't get these two features to work together. I really need six different styles, three for one theme (dark) and three for the other (light), but I can't figure out how to choose a style for a list item based on the current theme, or get that effect any other way by using XML files. My three layouts each point to a custom theme that sets the color, but that overrides whatever theme I've got set. Themes can only contain items that are "styleable", so I can't put my own custom items in there. There may be a way to do this programmatically, but I was hoping to do it declaratively. Any ideas?
Thanks to wingman for the hint. My situation involved colors, which are a bit more complicated, so I'll write up my solution here.
I have two themes (light and dark) which the user can choose from in the Settings screen. I have a ListView which can have two types of rows (plain and note), each with its own styling. Firstly each layout needs to point to a style:
<TextView style="#style/PlainItemText" ... />
(or NoteItemText) and we need to define the styles:
<style name="PlainItemText">
<item name="android:textSize">#dimen/list_item_font_size</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">?plainTextColor</item>
</style>
The text color can't be fixed because it depends on the selected theme. We must create a custom attribute and refer to it with a question mark, as above. We define the attribute in res/values/attrs.xml:
<!-- Attributes we use to set the text color of the various list items. -->
<attr name="plainTextColor" format="reference|color"/>
<attr name="noteTextColor" format="reference|color"/>
We can then define the various colors. Here we have two styles and two themes, so we need four color state lists, each in its own file under res/color. For example, here's res/color/plain_text_color_dark.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:color="#android:color/white"/>
<item android:state_selected="true" android:color="#android:color/black"/>
<item android:state_focused="true" android:color="#android:color/black"/>
<item android:state_pressed="true" android:color="#android:color/black"/>
<item android:color="#android:color/white"/>
</selector>
The selected/focused/pressed colors are the same in all these files because they're over the highlight color. Be careful with the state_window_focused version. It didn't behave as advertised, and I had to set it to the default color (the last line above) in all cases. Now we need to create our themes and bind the attributes to one of the colors. These lines go into res/values/themes.xml:
<style name="Theme.Dark" parent="android:Theme">
<item name="plainTextColor">#color/plain_text_color_dark</item>
<item name="noteTextColor">#color/note_text_color_dark</item>
</style>
<style name="Theme.Light" parent="android:Theme.Light">
<item name="plainTextColor">#color/plain_text_color_light</item>
<item name="noteTextColor">#color/note_text_color_light</item>
</style>
Finally we pick a theme at run-time, in an Activity's onCreate() method, before calling super.onCreate():
if (isDarkTheme) {
activity.setTheme(R.style.Theme_Dark);
} else {
activity.setTheme(R.style.Theme_Light);
}
Note that I don't take into account newer themes like Holo, so my app looks old on Honeycomb and later. I'll fix that at some point, but it wasn't a regression here.
A twist in my case is that some Activities have a larger title bar in order to fit some buttons. In principle I should have created four themes, a light and dark for a narrow title and a light and dark for a fat title. But instead I created a mix-in style:
<!-- Mix-in style for activities. -->
<style name="ButtonTitleBar">
<item name="android:windowTitleSize">44dp</item>
</style>
and procedurally add it to whatever theme I'm using. This code goes right after the above setTheme() calls:
if (buttonTitleBar) {
// Mix in this other style.
Resources.Theme theme = activity.getTheme();
theme.applyStyle(R.style.ButtonTitleBar, true);
}
I didn't see this documented anywhere, and I don't know if it's legit, but the code of Activity.getTheme() implies that it should work fine, and it has worked in all my testing. This can help avoid the combinatorial explosion of themes that you can find in the standard Android theme list.
It's a long time ago that Lawrence Kesteloot published his solution in 2012. Now it is six years later, a am new in Android and try to solve the similar problem:
How can I exchange the whole style of the application by just exchanging one theme?
This is a generalisation of Lawrences issue how to organise two exchangeable themes.
I figured out a solution based on Lawrence's and going a step further.
(Not claiming it is the perfect solution, yet an improvement.)
Lawrence figured out the power of user defined attributes to reach this goal. He uses them to address colours depending on the the currently selected theme.
While this is working it still requires to define attributes for each and every property. It doesn't scale well. So why not bundling the properties into styles and themes and using the same mechanism?
This results in a master theme, that is defining child themes and styles.
res/values/attrs.xml
<resources>
...
<attr name="mainViewTheme" format="string"/>
<attr name="asideViewTheme" format="string"/>
...
</resources>
When defining the attribute to set a theme, there is no special format for it. The format string does it.
res/values/styles.xml
<style name="MasterTheme">
...
<item name="mainViewTheme">#style/MainViewTheme</item>
<item name="asideViewTheme">#style/AsideViewTheme</item>
...
</style>
<style name="MainTextTheme">
...
</style>
<style name="MainViewTheme">
...
</style>
res/layouts/main.xml
<TextView
android:theme="?mainViewTheme"
...
By exchanging the master theme all styles are adjusted. It still requires the definition of a handful of theme attributes and then does a powerful job. Setting up attributes for every property is not required any more.
Currently, I'm using this to show my application background as phone wallpaper.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER,
WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);
But for some reason when I start my application by pressing the icon. It just shows the activity screen with the icons on the home screen. I didn't use dialog but it looks like a dialog because layout is just set that way. So I just want to show the wallpaper whenever this activity is running. But it only shows the wallpaper only after the next event occurs such as switching to different activity. I already put that code on onCreate() and whenever I do setContentView()..... Is there way to do such thing or there is just no way?
For users of AppCompat, just use the following in your styles.xml, no need for code:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowShowWallpaper">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
After long search and trial and error. I've found the solution to what I wanted. It was just creating separate themes.xml file and just tweak the Theme.Dialog which is already defined in default android themes.xml. All I did was change the Animation part. Originally in android themes.xml the line looks like this.
<item name="android:windowAnimationStyle">#android:style/Animation.Dialog</item>
but since modifying in android themes.xml doesn't take the effect. I just created my own themes.xml as I said above and just set parent as android:Theme.Dialog. And added a line like this.
<item name="android:windowAnimationStyle">#android:style/Animation</item>
Thanks for the help and I hope this solution helps others.
Use following code -
rl = (RelativeLayout)findViewById(R.id.someid);
//relative layout is my root node in main.xml (yours may be linearlayout)
WallpaperManager wm = WallpaperManager.getInstance(this);
Drawable d = wm.peekDrawable();
rl.setBackgroundDrawable(d);// You can also use rl.setBackgroundDrawable(getWallpaper);
How to change a style from code?
I got a style used all across my app, for all buttons. If the user changes the skin of the app, the background of this style should change.
<style name="ActionBtn">
<item name="android:layout_width">#dimen/action_btn_width</item>
<item name="android:layout_height">#dimen/action_btn_height</item>
<item name="android:background">#drawable/btn_frame_bgstate</item>
<item name="android:padding">#dimen/action_btn_padding</item>
<item name="android:layout_margin">#dimen/action_btn_margin</item>
</style>
So far the only idea I got is to make a custom button that itself chooses its background on creation.
I have not found any good, generic way for skinning android apps yet, but if I could change styles from code, that would do the trick.
All suggestions welcome!
1) Create different themes for your skins.
2) Set those themes programatically using following code in your onCreate method.
setTheme(resid);
resid is the id of your theme.