I use adjustPan to automatically pan my application to make the EditText field visible when the softkeyboard appears. So far this has worked well but in the latest Android 4.4 Kitkat versions the actionbar pans up as usual but a white box is left behind. I've tried debugging this with the Eclipse View Hierarchy tool but it ignores the box. I've also experimented with v19 styling with no luck. This happens on a variety of Kitkat Nexus devices and emulators.
I'm happy to leave the actionbar on screen or remove it completely when the windows pans. Any help would be appreciated removing the box.
I found that this only happens with the applications hardware acceleration is set to true in the manifest file.
I want to keep the hardware acceleration turned on so I wrote this snippet inside my onCreate method to turn it off just the action bar container.
if(Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
Resources res = Resources.getSystem();
int id = res.getIdentifier("action_bar_overlay_layout", "id", "android");
ViewGroup overlayLayout = (ViewGroup) this.findViewById(id);
overlayLayout.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
UPDATE
This issue has been fixed in Android L preview API 20. Please note that the above code will cause an exception in Android L and so the version condition needs to be explicit to Kitkat.
if(Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
Related
I am following this answer to construct settings of my application. My problem is that I get titlebar for nested PreferenceScreen elements. I tried to apply themes which turn off windowTitle. I tried to request window feature. But I was not successful. This problem is only on Gingerbread & Honeycomb. Post-Honeycomb everything works fine. Here is an image which shows two window titles one by me (this answer), another by system.
Can someone help me to hide titlebar set by window? I am pretty sure it can be achieved but Whatsapp Developers won't answer me :)
Finally I managed to hide the titlebar with
View titleView = dialog.findViewById(android.R.id.title);
if (titleView != null) {
((View)titleView.getParent()).setVisibility(View.GONE);
}
in accordance with the code in answer for Gingerbread & Honeycomb. Well with the if condition code can be written out of condition of being run only on Gingerbread & Honeycomb as post Honeycomb I have found titleView != null false.
I have developed some custom behaviours for a TextView that changes position and size based on the height of the AppBarLayout inside a CoordinatorLayout. This is so that the title appears large and in the centre of the fully expanded Toolbar when open, but in the normal title position when the ToolBar is fully collapsed.
Take a look at the videos to see it on a Lollipop device (not working correctly) and a JellyBean device (working fine).
The issue occurs (I believe, based on my tests) on Lollipop devices only, and it seems to be linked to the fact that the status bar is an overlay on the Lollipop device, but not on the JellyBean one. This is reflected in my code as well, where to calculate the final y positions I need to do the following for the final position to be correct:
if (mFinalYPosition == 0) {
mFinalYPosition = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
? (((mContext.getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_default_height_material)/2)) + getStatusBarHeight())
: ((mContext.getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_default_height_material)/2));
}
The best solution for me would be if I could have Lollipop devices treat the status bar in the same as earlier Android versions, i.e. in a locked position, and not as an overlay.
How would I go about achieving this?
I was able to resolve this issue by removing all android:fitsSystemWindows elements from my layout xml file. In addition, it may be clear from the video I posted that some views disappeared during the animations on my Lollipop device then reappeared later. I was able to fix this by setting the elevation on certain Views to ensure they didn't vanish behind others during animation.
I dim the background of a DialogFragment using this code:
Window window = getDialog().getWindow();
WindowManager.LayoutParams windowParams = window.getAttributes();
windowParams.dimAmount = 0.75f;
windowParams.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND;
window.setAttributes(windowParams);
This works fine on Kitkat and below, but stopped working on Lollipop. I suspect it has to do with the fact that my Activity is using the style Theme.AppCompat.Light.DarkActionBar, which uses the Material Theme on 5.x, and something in that theme prevents the DIM flag from working.
I tried messing with the various theme flags, but to no avail so far.
Apparently this was caused by Lux Dash app I had installed, that controls the brightness of the screen. Geesh. Took me a while to figure this out!
I uninstalled it and the dimming came back. [Not a bug]
A bunch of the ActionBarActivities have been Depreciated on the newer OS's with android. I just created one and had a similar problem with android 5.0 and i think the newer 5. 1 So i kind of found a solution(If this doesn't work for you just try an earlier version of android), If your in android studio on the left left click on project then right click on app. a menu should pop up then click on Module Settings... In there there should be a build tools scroll down, If the current one is set to the new beta version set it to 21.1.10 and the Compile sdk version to 5.0 and that worked for me.. Try it if not mess with the build tools version a little (THE NEW VERSION IS SOMETHING LIKE 23.0.0 rc1)
Background
I've made an "app manager" alternative app, and I wish to add translation for RTL (right to left) languages.
Since I know that as of certain Android version, things got flipped to let words and sentences align correctly, I decided to first switch to such a language and then continue with the translation
The problem
After switching to an RTL language (Hebrew in my case), I've found out that the action bar's up button has the "<" image flipped horizontally:
So now it shows ">" instead.
The question
How do I fix it? It doesn't make sense to see it this way...
What worked for me was to let the system use the default theme, and not specify Holo. If you can live with that, the Up button will be oriented correctly. Unfortunately this cannot be done if you use AppCompat of course.
To make this even more annoying: the flipping of the up button is device specific. It occurs on Samsung devices but not on Google's. The supportsRtl flag is only for API 17 and above, so older Samsung phones cannot be fixed.
The issue is apparently the Holo implementation on Samsung devices. Be careful with flipping the icon since on Google phones it will be flipped wrong.
See this: https://code.google.com/p/android/issues/detail?id=68476
Well, you can access that ActionBar "up" affordance by calling Resources.getIdentifier and View.findViewById. After that you could rotate it.
final int upId = getResources().getIdentifier("up", "id", "android");
final View up = findViewById(upId);
// Call this to just rotate the icon 180°
if (getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
up.setRotation(180f);
}
I am trying to implement an action bar with tabs as navigation options. To do that I select the "Tabs+Swipe" option in the "New Blank Activity" section of the "New Android App" wizard as shown below.
Now, in the android manifest, when
android:targetSdkVersion="15"
which is the default value, the action bar looks like this on a Nexus 7/Nexus 7 emulator, this is the desired look of the app
Now when I change that line in the android manifest to
android:targetSdkVersion="16"
the look of the action bar changes to this
The default look remains for any version of android but 16, can anyone please explain why the look of the action bar suddenly changes when the targetSdkVersion is set to 16?
The above is reproducible in the emulator as as well as on a real nexus 7.
Full screengrabs for
Normal: http://i.stack.imgur.com/VsBA2.png
After android:targetSdkVersion="16": http://i.stack.imgur.com/OM6Y4.png
Update-10th March, 2013: Switched to the List Navigation mode (instead of Tabs) to enable move to android:targetSdkVersion=17
The reason it changes when setting targetSDK to 16 is because Google changed how tabs are measured in Jelly Bean. Specifically, look at this in android.internal.view.ActionBarPolicy:
public boolean hasEmbeddedTabs() {
final int targetSdk = mContext.getApplicationInfo().targetSdkVersion;
if (targetSdk >= Build.VERSION_CODES.JELLY_BEAN) {
return mContext.getResources().getBoolean(R.bool.action_bar_embed_tabs);
}
// The embedded tabs policy changed in Jellybean; give older apps the old policy
// so they get what they expect.
return mContext.getResources().getBoolean(R.bool.action_bar_embed_tabs_pre_jb);
}
However, I suspect you don't just want the reason, but a solution. Unfortunately, I can't give you a straightforward way to set it to only embedded.
I can suggest using ActionBarSherlock to make it consistent, though. The bonus to that is the ability to use actionbars on older devices. When using it(portrait), I can confirm that if you set the targetSDK to 16, it uses the stacked layout on Jelly Bean, Ice Cream Sandwich, GingerBread, and Froyo. At least you will be able to design your layout while knowing what to expect.
Keep in mind that in most cases, switching to landscape mode will embed them in the actionbar again, since there is "enough room" the way it measures.