How to keep same background in the whole application? - android

How can I make my application have the same background everywhere? I've tried to do it with editing the theme but the problem there was that my app uses an animation in which, when you go to an new layout it slides over. So want I want is a way to have the same background everywhere and when a new layout slides in only textviews and buttons and sh*t should move. The background has to stand still at the same position.
Also, what is the best size for an background within an app? 1080x1920 is a bit slow :P
THANKS!!
What i've tried: (values/styles.xml)
<resources>
<!-- Base application theme. -->
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="#style/Theme.AppCompat.Light">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:background">#drawable/background</item>
</style>
(androidmanifest)
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/Theme.AppCompat.Light.NoActionBar.FullScreen" >
// unimportant things here
</application>

You can just set the background you need in the config file. Once you've done that, simple make sure you don't set the background anywhere else and you should be okay.

Related

how to make android activity default background

hey i want a default screen when my android activity is loading...usually it creates a fully black background effect..that may confuse users..
so i try this code
create a file inside res/values/theme.xml
then put this code..
<resources>
<style name="Theme.MyAppTheme" parent="android:style/Theme" >
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowBackground">#drawable/bid_screen_preparing</item>
</style>
</resources>
I also added this file in manifest file like
<application
android:allowBackup="true"
android:allowClearUserData="true"
android:icon="#drawable/bid_icon"
android:label="#string/app_name"
android:logo="#drawable/bid_logo"
android:theme="#style/Theme.MyAppTheme" > ........
It works only when i press back button and activity back to his previous one..But when i load one activity to another then it asusual shows the black color...dont know why..
please change these line
<resources>
<style name="Theme.MyAppTheme" parent="android:style/Theme" >
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowBackground">#drawable/bid_screen_preparing</item>
</style>
</resources>
and use these lines
<resources>
<style name="MyAppTheme" parent="android:style/Theme.light" >
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowBackground">#drawable/bid_screen_preparing</item>
</style>
</resources>
and remove these lines
<application
android:allowBackup="true"
android:allowClearUserData="true"
android:icon="#drawable/bid_icon"
android:label="#string/app_name"
android:logo="#drawable/bid_logo"
android:theme="#style/Theme.MyAppTheme" > ........
to
<application
android:allowBackup="true"
android:allowClearUserData="true"
android:icon="#drawable/bid_icon"
android:label="#string/app_name"
android:logo="#drawable/bid_logo"
android:theme="#style/MyAppTheme" > ........
It works only when i press back button and activity back to his previous one..But when i load one activity to another then it asusual shows the black color...dont know why..
This is how the system works - if you're just jumping from one activity to the next (like by calling startActivity() from onCreate(), the system won't bother drawing anything to prevent a flickering effect (this was explained by Dianne Hackborn a while back on the Android Developer forums).
If you're trying to implement a loading screen, you need to spawn off an AsyncTask that does the loading work off the main thread then starts the next activity when it's finished. Then your first activity will have time to draw the "loading" message.

Android normal button turns transparent

I have a RelativeLayout with a background set with android:background="#drawable/background".
In my RelativeLayout` I have a standard button but when I run the app in devices running 3.1 or higher the button are displayed transparent.
I have tried setting android:alpha to 1 with no luck.
I know I can make a custom background with selector and shapes but there has to be another way.
Anyone else had this problem?
You'll want to add something like this to your style.xml
Application theme
<style name="ApplicationStyle" parent="android:Theme">
<item name="android:buttonStyle">#style/MyButtons</item>
</style>
Button style
<style name="MyButtons" parent="#android:style/Widget.Button">
<item name="android:textSize">16sp</item>
<item name="android:background">#000000</item>
</style>
Make sure you're setting your theme correctly in the manifest also
<application
android:allowBackup="true"
android:icon="#drawable/app_icon"
android:label="#string/app_name"
android:theme="#style/Theme.ApplicationStyle" >

Why there is a white screen appears for 1sec when starting to run the apps in Android?

When I click the app icons and start to run the apps, it will appear a white screen for 1 sec.
I don't know why.
Is there any idea to clear this white screen and directly go to my activity?
The white/black screen is the window background image.
The window background is shown while e.g. your onCreate() runs and your layouts are being inflated. It can take some time especially if there's a lot of bitmaps that need to be read, decoded and scaled.
Changing the theme works because some themes have a non-default window background. For example, Theme.Wallpaper has a transparent background. There are other definitions there, too. Essentially what you want is:
<style name="YourTheme">
<item name="android:windowBackground">#null</item>
</style>
Programmatically you can achieve the same with
getWindow().setBackgroundDrawable(null);
at the top of activity onCreate().
(Old question but got bumped up by another answer and there wasn't a good answer.)
Settings. File>Settings>Build,Deployment>Instant Run Deselect all options shown there.
and add below line in your style.xml
<item name="android:windowDisablePreview">true</item>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowDisablePreview">true</item>
</style>
apply changes in AndroidMainfest.xml
<application
android:theme="#style/AppTheme">
After I change style.xml:
<resources>
<style name="AppTheme" parent="android:Theme.Wallpaper" />
</resources>
it works!!
Thanks all
Add the following in the manifest file of the corresponding activity
android:launchMode="standard"
and remove android:label="#string/app_name" from the corresponding activity ,this actually helped me
In your manifest.xml file remove the line android:theme="#style/AppTheme" for your app. and check it again
Use this tag in your manifest:
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
In Styles add the following things
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowIsTranslucent">true</item>
Hope this will help you and its working for me

set background Image to whole application in android

I want to set background image to my application in android. So my application already has a theme set in my manifest file like this
<application android:theme="#android:style/Theme.NoTitleBar" />
Now this was implemented from the themes of android package.
Now i want to add a background image to my entire application how can i do it.
<style name="Theme.NoTitleBar.BackgroundImage">
<item name="android:background">#drawable/bitzer_background</item>
</style>
I want the Theme.NoTitleBar as well.
I have changed the style below, by doing this I am overriding the Theme.NoTitlteBar
<style name="Background" parent="#android:style/Theme.NoTitleBar">
<item name="android:windowBackground">#android:color/black</item>
<item name="android:windowNoTitle">true</item>
</style>
Now my manifest file looks like this:
<application android:theme="#style/Background"/>
You have to use styles to achieve this
Check out this link
Create a theme with your background and use that theme.

Is it possible to change android background black colour?

Is it possible to change the colour of background while switching between activities?
I mean the black colour what apear while one of activities disappear and before second appear. Thanks.
Just you need to head over to the activity_home.xml
At the starting lines of code add this background parameter to set the screen black
android:background="#ffffff"
you may change the theme that you are using as follows:
application android:icon="#drawable/icon" android:label="#string/app_name"
android:theme="#android:style/Theme.Light" >
Edit
as mentioned in the documentation:
<application android:theme="#style/CustomTheme">
and then tweak the theme that you like:
<style>
<color name="custom_theme_color">#b0b0ff</color>
<style name="CustomTheme" parent="android:Theme.Light">
<item name="android:windowBackground">#color/custom_theme_color</item>
<item name="android:colorBackground">#color/custom_theme_color</item>
</style>
here is the link to the topic http://developer.android.com/guide/topics/ui/themes.html#ApplyATheme

Categories

Resources