I have a transparent activity defined using this theme:
<style name="Theme.Transparent.NoDim" parent="android:Theme.Translucent">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
And in the AndroidManifest.xml
<activity android:name=".Activity"
android:theme="#style/Theme.Transparent.NoDim">
</activity>
However since adding this theme to the Activity, when opened the Activity does not open using the normal animation (where the view expands to fill the screen), rather it just suddenly appears.
Any ideas on why, and a fix?
Thank you!
Related
I am creating an activity and adding views to it dynamically. This activity contains an imageview and a close button. I want the background of the image which is in fact the relative layout background to be transparent so that the icons on the home screen of the device could be visible.
I have tried
Window window = this.getWindow();
window.setBackgroundDrawable(newColorDrawable(android.graphics.Color.TRANSPARENT));
and also
relativeLayout.setBackgroundColor(Color.parseColor("#00000000"));
and this as well
relativeLayout.setBackgroundColor(0x00000000);
Nothing seems to work. Any pointers will be appreciated. Thanks.
you can create theme and use it for activity
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
<activity android:name=".SampleActivity" android:theme="#style/Theme.Transparent"/>
Define style theme for particular Activity.
In style.xml file
<style name="DialogTheme" parent="android:Theme.Holo.Light.Dialog">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
</style>
And associate this style in Manifest with activity
<activity
android:name="com.pac.activity.YOURACTIVITY"
android:screenOrientation="portrait"
android:theme="#style/DialogTheme" >
</activity>
Hi use this link http://angrytools.com/android/button/. its help for you
Set the
android:background="#android:color/transparent"
Also the colour hexa you are using is wrong...
00000000 is hexa for non transparent white
Use
Ff000000 instead
In the top most viewgroup you have. This will essentially create a background with transparent colour on which other views will lie.
You can adjust transparency using other colours in that place.
I am trying to remove white screen before splash so i followed solutions mentioned in these links
How To fix white screen on app Start up?
White screen before splashscreen
I tried almost every solution mentioned here
which includes changing activity theme to this
android:theme="#android:style/Theme.Translucent.NoTitleBar"
or adding this to my theme
<item name="android:windowDisablePreview">true</item>
but implementing any of this freezes the UI for a while on click of the App icon after that everything works fine as desired.
Has anyone succeeded to fix this lag. Any help will be appreciated.
create a custom theme like,
//splashTheme
//create in styles
<style name="splashTheme" parent="AppTheme">
<!-- Customize your theme here. -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
and then apply the theme as follows,
//manifest file
<activity
android:name=".SplashActivity"
android:theme="#style/AppTheme.splashTheme"
android:windowSoftInputMode="adjustResize|stateHidden" />
try this.
following changes work for me on mac:
1.Goto android studio preferences.
2.In Build,Execution and Deployment select "Instant run".
3.disable-Enable instant run to hot swap code/resource changes on deploy.
4.apply changes,clean project and rebuild again.
Finally got my answer Splash Screen in Right Way. I do just following.
In values-->styles.xml I created splash screen background image
<style name="Splash" parent="AppTheme.NoActionBar">
<item name="android:windowBackground">#drawable/splash</item>
</style>
For below api 19, in values-19->styles.xml I used
<style name="Splash" parent="AppTheme.NoActionBar">
<item name="android:windowBackground">#drawable/splash</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
I removed setContentview() from SplashActivity and added style for splash screen in Manifest.xml file android:theme="#style/Splash"
I have an application where the theme can be changed between three different ones. I have two activities that are supposed to have a transparent background and look like a dialog above the previous activity.
I've searched alot for transparent activities here on stack and most of them have the same awnsers. A custom theme with a few properties to enable a transparent background for the activity in question.
The issue for me is that i need to set this custom transparent theme on the parent activity as well to achieve any transparency at all. If i only set a transparent theme on the activity i want to be transparent, it will be a solid background. I've tried everything i could think of but it all boils down to this and im not sure what im doing wrong.
This is my two different parent themes (slimmed down to the neccesary parts):
<style name="StyledActionbar" parent="Theme.Sherlock.Light.ForceOverflow">
<item name="android:textViewStyle">#style/Iksu.TextView</item>
<item name="windowContentOverlay">#null</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<style name="Transparent" parent="Theme.Sherlock.Light.ForceOverflow">
<item name="android:textViewStyle">#style/TextView</item>
<item name="windowContentOverlay">#null</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowIsTranslucent">true</item>
</style>
StyledActionBar is the parent for my three different main themes that is used for all activities that are not supposed to have a transparent background (which is all but two).
Transparent is the parent for three themes that can be used on an activity where the background needs to be transparent.
So the parent activity has a theme based on the StyledActionBar theme. The activity i need to have transparent is based on the Transparent theme.
The background is solid in this state.
If i move:
<item name="android:windowIsTranslucent">true</item>
to StyledActionBar, almost everything works as a charm except a nasty bug in Android 4.4.2 causing the main activity to "fall behind" the OS view when using NavUtils for up-navigation to the main activity.
Any ideas?
in your manigest file
<activity
android:theme="#android:style/Theme.Translucent.NoTitleBar">
</activity>
and in your xml set
android:background="#android/transperent"
also you can use
android:alpha="0.50"
try this one more time :
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
and in the manifest file
<activity android:name=".AlertActivity"
android:theme="#style/Theme.Transparent"/>
Hope it will work for u.
I am trying to crate a Custom UI similar to evernote help android app. As I understand, to start with I have to first create a custom Textview But i cant create a black filter.
I want make new help activity(or draw a view) above the original activity like above image.
My layout has an image and text overlay on it. I know it is a basic question, but I am facing this issue, as I am a beginner to android development. Please do help me to understand how to go with this.
sorry for my bad english.
To make the help activity transprent first make a transprent theme in the styles.xml file in valuse folded using
<style name="AppTheme" parent="android:Theme.Light" />
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
then make in the manifest file make this as the theme of your help activty
<activity
android:name=".Help"
android:theme="#style/Theme.Transparent"
android:screenOrientation="portrait"></activity>
now in the help activty will be displayed over your prvious activity.
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