When I use
getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
in my Activity I don't get slightly blurred screen under current Activity but completely black one (top Activity is fine). Need to say it is also black in sample which came with SDK. Can somebody suggest how to make it blurry?
In your AndroidManifest.xml add this line to your Activity declaration: android:theme="#android:style/Theme.Translucent.NoTitleBar" otherwise the activity will have a solid background (and thus blur has no effect).
Also, this post on StackOverflow is helpful, in particular the cautionary notes. On older devices this causes your application to become unresponsive (it is a CPU-intense software rendering), and on newer devices this constant is deprecated and no longer has any effect (see Android Documentation for WindowManager.LayoutParams).
Deprecated on latest versions of OS (check documentation).
Note: the flag FLAG_BLUR_BEHIND is depreciated.
You can use FLAG_DIM_BEHIND Instead.
Related
I do understand that similar issues have been reported here but mine is somewhat different.
I have recently upgraded the com.android.support:appcompat-v7 to v21 and com.android.support:support-v4 to v19.
Everything seemed normal on a pre-lollipop device but when I started to test the device on Android L, two issues appeared:
The softkeyboard was covering EditText
In the webview, system wasn't resizing, pushing the form-fields to the top as it normally should, rather did on pre-lollipop devices.
I read various articles and added the following line to my AndroidManifest.xml file:
android:windowSoftInputMode="adjustPan". It did push the edittextfields on top of the keyboard removing the toolbar from the view however it did not resize the view in webview and still covered the form fields at the bottom.
And after the changes, the app on pre-lollipop devices is malfunctioning in the same fashion as well.
Any help will be very much appreciated.
Extract from android-manifest:
<activity
.....
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan">
...
</activity>
I am using the Theme.AppCompat.Light.NoActionBar theme for my app.
Incase anyone lands here facing the same issue, the behavior occurs because "they" (Google) have changed the behavior of adjustPan moving forward from Android L.
To fix the issue, I am using a keyboard util in the library as indicated here.
A note from the developer is that this fix is to be used only in fragment/activity becaues this uses a GlobalLayoutListener which lowers the frameRate a bit but this is the only option to get it working
At the moment, I'm stuck with a very annoying kind of "bug" I assume regarding all Pre-Lollipop Android versions. It appears that (support) fragments don't apply the activity's theme they're assigned to. To make my explanations a bit easier, have the following demonstration:
My app runs with a turquoise theme at first. Let's say, the user decided to change the turquoise theme to a red theme. He or she restarts the app and is greeted with the following:
(screenshot taken on an Android 4.4.2 tablet)
Terrible sight, isn't it? However, if I run the same app in an emulator with Android L the whole theme problem doesn't even seem to exist.
There's especially one thing which seems odd about the tablet screenshot. The fragment itself doesn't apply the theme but child components inside the fragment which get added lateron (like the view with the exclamation mark which is hosted by a ViewPager) take and apply the theme as if nothing happened.
I'm not quite sure what the issue might be. I've done everything as stated in every document available. I set the theme before I call setContentView(resource) in the corresponding activity. I tried to do the trick with ContextThemeWrapper but it was no use.
Relevant code:
The activity's onCreate()
The fragment's onCreateView()
The fragment's layout
Attributes
Themes (a lot of them)
I tried to resolve this issue for days now and I still can't find out why this is not working. I haven't found a suitable answer yet and would love some advise.
I've been the victim to my own stupidity. I had another close look on my project setup and found this:
My tablet takes its layout resources from the sw600dp-folder, but I forgot to change the corresponding layout to take attributes instead of hardcoded colors. I think I have to retire after making such a stupid mistake.
I'm developing an Android application which uses ActionBarSherlock (ABS) and needs to work in API >=8. The problem is that some transitions between activities aren't smooth enough.
For example: I have two activities, (A) one which is always fullscreen and (B) another one which isn't fullscreen (status bar and action bar are shown). The transition needed is always from A to B. When it occurs and B activity is loaded, all the content (included ABS) is shown as if the activity was fullscreen and then resizes when the status bar is loaded again.
In some devices this effect is insignificant but in other ones it becomes really annoying and even causes that the user touches the wrong section of the view.
Fullscreen declaration is made via Manifest activity's "theme" property (anything by code). For example:
<activity
android:name = "...."
android:screenOrientation = "portrait"
android:theme = "#android:style/Theme.NoTitleBar.Fullscreen">
</activity>
Searching on the Internet for some solution, I've found two main approaches:
1) To use the Android appcompat library and enabling action bar overlay as mentioned here: https://developer.android.com/training/basics/actionbar/overlaying.html#EnableOverlay.
The problem with this is that the app also uses the HoloEverywhere library and many errors appeared when using HoloEverywhere + appcompat. All this errors were related to duplicated XML elements. I've also checked android-support-v4 library in all projects to avoid errors.
2) Using WindowManager flags and applying top padding to the view: http://nubinewsblog.blogspot.com.es/2009/11/smooth-full-screen-transition.html.
With this approach the transition is perfect. The biggest problem - and the reason I need to ask this - is that I'm not able to apply a top margin to ABS and the status bar is shown over the action bar. I can move down all elements except ABS. I suppose it occurs because ABS uses many fixed dimensions and attributes.
I prefer to use the second way (2) but I can try everything needed to make the transition smoother. Any further implementation details needed can be asked and I'll try to answer ASAP. I'd be very grateful for any info or help provided :-)
Really thanks to all for your time.
PS: I'm currently using and Android 2.3.6 device for testing.
PS: when I say fullscreen I always refer to fullscreen + no status bar + no action bar.
I've solved my problem doing the following:
1.- I have to optimize all the screens where the AB was shown. In some cases I used ListViews which weren't correctly implemented and that caused a noticeable load time in the activity.
2.- I have shown the status bar BEFORE starting the new activity. I mean: I've shown the status bar in the fullscreen activity just before starting the non-fullscreen one. With that I achieved that the layout of the second activity (non-fullscreen) was never resized.
With this two little changes now the AB transition is much more smoother.
I close this question but, if someone has any doubt, I will be pleased to answer it. Last but not least, ¡thanks to all who tried to help with this problem!
the best solution is to clear full screen flags on onPause method of first (full screen) activity
#Override
protected void onPause(){
super.onPause();
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
The last few days I've been doing great stuff in development, but I've seem to have hit a wall on something probably stupid simple. It's annoying. I was hoping I could get some help.
What I'm trying to do
I'm trying to create the awesome transparent ActionBar animation effect from Google Music (as described by Cyril Mottier here)
The problem
I can't even get the actionbar to go into overlay / transparent mode.
My set-up
I've got a library-oriented set-up in Eclipse. I've got a library project (let's call it master) that contains all the actual code and activities. Then I've got a project, that just plugs into the master library (let's call it slave). Lastly there's some open source support libraries that master uses (among others is ActionBarSherlock).
The activity I'm trying to apply this effect to is in the master library. It is declared in slave's manifest as com.example.master.DetailActivity, and that works like a charm.
Also: The theme for the activity may come from several places. Either it's set by slave's manifest, or by master at runtime. Themes may come from the master OR the slave project.
What I've tried
Feels like everything. I've started out by creating a custom theme based on Cyril's article. I made sure that for every item I've had a version with and without the android: prefix as per Jake Wharton's instructions.
I've also tried setting it at runtime using requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
What I've got
Nothing. The theme applied succesfully (I can see the actionbar's colors change appropriately), but it NEVER goes into overlay mode, nor does it become transparent.
Help would be greatly appreciated, and would probably be helpful to other's trying this effect.
EDIT:
Here are my themes and styles. Codes are kinda messy because I've been experimenting with them to see where I was going wrong. AppTheme and Theme.TranslucentActionBar.ActionBar.Overlay both won't work.
/res/values/
styles.xml
themes.xml
/res/values-v11/
styles.xml
themes.xml
I'm testing on a Nexus 4 with 4.2.2 installed as well as a 2.3.3 emulator.
OK, so apparently, with my set-up, you can't do it using themes.
I ended it up doing it, globally like this.
setTheme(theme.whatever);
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
super.onCreate(savedInstanceState);
setContentView(R.layout.content);
getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.color)); // This is #212121 solid color for the dark action bar.
The lines are spread out over my code, but this is the gist of it. The order is important.
I also found out that sliding menu seemed to be blocking the overlay mode. I had to remove the instance for it to work. I'm still looking for a way to enable both overlay mode and the sliding menu.
I'm designing a custom Android 4.0 (ICS) device for special purpose.
One of the things I'm looking for is a way to make the Android Launcher, when other activities were previously running, show the last running activity as a transparent, dimmed background, with the launcher icons and widgets on top.
What I'm looking for, is something like this: How do I create a transparent Activity on Android?, except as a modification to Launcher2. I guess I can apply a similar style to the launcher as proposed in that SO, but what about the wallpaper?
AFAIU, the wallpaper is rendered by a separate service, and I still want it rendered if there are no other activities behind the launcher.
Any tips?
I figured this one out myself eventually. It turned out pretty simple.
Just modify the theme as suggested in the mentioned SO-article, and simply change inheritance from the Wallpaper-enabled theme.
Also, there were a small code-snippet that was reactivating the wallpaper. Switch that out, and I've now got a transparent launcher, that shows what's going on behind it.