I want this kind of translucent activity/fragment for android any help would be appreciated
Android activity/fragment overlapping here just like this one:
use this style for your app :
<style name="AppTheme.NoBackGround">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowBackground">#color/transparent</item>
<item name="android:colorBackgroundCacheHint">#color/transparent</item>
</style>
then set the blur and transparent background on the activity
Related
I have a specifix view that needs to use windowIsTranslucent = true. This generates some problems that I'm having hard time to understand... the specific one that I'm trying to resolve now is why the transition in/out changes to slide up / down only because of this style.
I want to use windowIsTranslucent = true but with the standard activity transition animation.
These are relevant styles
<style name="AppTheme.AppCompat.Translucent" parent="AppTheme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#color/opacity_background</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:statusBarColor">#07819A</item>
<item name="android:actionMenuTextColor">#color/White</item>
<item name="android:windowDisablePreview">true</item>
<item name="colorPrimary">#07819A</item>
<item name="colorPrimaryDark">#006471</item>
<item name="android:fastScrollTextColor">#ffffff</item>
<item name="android:dropDownListViewStyle">#style/FilterSpinnerStyle</item>
<item name="android:actionOverflowButtonStyle">#style/AppTheme.OverFlow</item>
<item name="android:autofilledHighlight">#android:color/transparent</item>
</style>
What I have tried witout success:
Added this line to AppTheme.AppCompat.Translucent
<item name="android:windowAnimationStyle">#+android:style/Animation.Translucent</item>
Added this line to AppTheme.AppCompat.Translucent
<item name="android:windowAnimationStyle">#+android:style/Animation.Activity</item>
Used CurrentActivity.OverridePendingTransition(someId, someId); and it works. The problem is that animation is a little laggy when I try to mimic standard animation and I also have the problem to use the correct animation for each version of Android.
I tried some other things that I don't have at the top of my head right now... the thing is that nothing seems to be enough :(
You can override the default transition animation for your app by declaring a custom style with your desired animations like this:
<style name="CustomAnimation" parent="#android:style/Animation.Activity">
<item name="android:activityOpenEnterAnimation">#anim/your_desired_animation</item>
<item name="android:activityOpenExitAnimation">#anim/your_desired_animation</item>
<item name="android:activityCloseEnterAnimation">#anim/your_desired_animation</item>
<item name="android:activityCloseExitAnimation">#anim/your_desired_animation</item>
</style>
And then by setting it to your base theme you can set the custom transition animation for your app
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">
<!-- Customize your theme here. -->
...
<item name="android:windowAnimationStyle">#style/CustomAnimation</item>
</style>
Thus you can declare your own transition animations. Even if the standard animations not working, you can always make your own like the standard one.
I have this style for Buttons in my Android app, but I don't want that little shadow.
<style name="AppTheme.Button.Primary" parent="#android:style/Widget.Holo.Button">
<item name="android:background">#color/primary_dark</item>
<item name="android:textColor">#color/primary_light</item>
<item name="android:gravity">center</item>
<item name="android:textSize">15sp</item>
<item name="android:layout_width">20dp</item>
<item name="android:layout_height">20dp</item>
<item name="android:layout_centerHorizontal">true</item>
</style>
The button looks like this:
Button image
Which item have to add in order to delete the overlay?
Thanks a lot!
Solved, I was applying the Material Light theme, so I changed it to my style and when I run the app no overlay is showed. Thanks.
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 want to get rid of the white color during the short period when my app is launching but the content isn't displayed, yet.
My main activity is using a style (from the Manifest) that extends #style/Theme.Sherlock.Light.DarkActionBar with the background set to <item name="android:background">#android:color/transparent</item>. Nowhere in my layout do I use a white background color, yet it appears for a brief moment during app launch.
In the HierarchyViewer I exported the layers and checked back that there is really no white solid in the layout hierarchy.
What setting controls the background color before the layout is drawn? Thanks.
There's another background attribute in your theme - windowBackground, and you implicitly set it to white by inheriting your style from #style/Theme.Sherlock.Light.DarkActionBar (notice the .Light. part in the name).
You can either use dark version of theme or set it explicitly by including windowBackground in your style definition:
<item name="android:windowBackground">#color/your_color</item>
<style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowIsTranslucent">true</item>
</style>
Or you can use drawable. I created a theme for my spash screen like as below :)
<style name="SceneTheme.Light.NoActionBar" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="SceneTheme.Light.NoActionBar.Transparent.StatusBar" parent="SceneTheme.Light.NoActionBar">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowBackground">#drawable/bg_splash</item>
</style>
I want my activity to look like a dialog.
Well, I achieved that using android:theme="#android:style/Theme.Dialog"
Now, I also want it to be translucent as it appears in android:theme="#android:style/Theme.Translucent"
Is there a a way to mix them both using a custom style??
Please any suggestions, thanks
EDIT: achieved something similar with this:
Now i want to add border like a dialogwindow...how can i do that???
<style name="TransparentDialog" parent="#android:style/Theme.Dialog">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowFrame">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:alertDialogStyle">#android:style/Theme.Dialog</item>
<item name="android:windowAnimationStyle">#android:style/Animation.Dialog</item>
</style>
EDIT: Solved this. Check the answer
Finally achieved what i wanted with this:
Used this theme for my activity android:theme="#android:style/Theme.Translucent"
and gave this android:background="#android:drawable/dialog_frame"as background to the root element of my layout
That was so easy!
You'll need to combine the two themes together. One thing that might work is:
<style name="TranslucentDialog" parent="#android:style/Theme.Dialog">
<item name="android:background">"#33000000"</item>
</style>