How to hide titlebar of nested preference on Gingerbread & Honeycomb - android

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.

Related

Actionbar replaced with white box with AdjustPan on Kitkat

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) {

Smoother transition from fullscreen activity using ActionBarSherlock

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);
}

On Google TV How do I make Fullscreen Activity hide title and button properly?

It would seem that the Fullscreen Activity Demo/Template does not behave the same on Google TV with the way Status/Navigation/Action bar are handled. Note: to make the default template work on Honeycomb I had to make a slight change to the provided SystemUiHiderHoneycomb class (details)
Question: Should the Template work properly? (I think yes). Is there a good way of fixing it without special handling for Google TV detection? What's a good way of achieving the same result of hiding the title at the top and the button at the bottom?
Steps to reproduce:
Create new application via Android Tools wizard
Use Fullscreen Activity as first and only activity
perform code modification to SystemUiHiderHoneycomb class (details)
I tested this on a Google TV emulator and on a real device with the same result. (I also tested it without the change in step 3).
In the manifest, you need to ask for Theme.Holo.Light.noactionbar in your manifest.
There is a programmatic way to do this if you don't want to muck with the theme in the Manifest file.
See: http://emergentbit.blogspot.com/2012/12/andorid-quick-tip-remove-title-bar-from.html
TL;DR
// Remove title bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
// Remove notification bar
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

Custom titlebar (summary) in PreferenceActivity

As the title suggests I want to create a custom title bar for a PreferenceAcitvity.
I need to add a summary below the title. Currently it will only display a title, but I need a sub-title, just like any Preference can have a summary.
I have read loads of questions here, like this and this, but these all do something different; it's not possible to include a summary for the title with the first method. Creating a custom layout for every Preference also doesn't seem the wisest option, and is loads of meaningless work (I have tons of PreferenceActivity's. I am looking into extending something.
Also, I want to keep the default behaviour as much as possible, so I am looking into ways of adding a TextView to the default layout located in android-sdk-windows\platforms\android-16\data\res\layout\screen_title.xml
So I thought I would apply this layout to the method in the second Q, but now I run into the problem of resource id's used in the screen_title.xml file that aren't public.
I'm running out of ideas...anyone got some fresh ones?
EDIT:
I found a solution thanks to the accepted answer below.
To clarify a bit further: the method getSupportActionBar() in the answer isn't in the SDK, but comes from ActionBarSherlock.
This is a compatibility library to enable the ActionBar and FragmentActivity (amongst other things) on pre API 11 applications/ devices. It's quite a heavy library, around 11mb, so you will have to think about if it's worth adding 11mb to your application just to have a summary/ subtitle in your preference screen's. On the other hand, this ofcourse also allows you to implement the other features of the library, such as actually creating an action bar (and or menu).
If you are talking about Actionbar then you can do this:
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setSubtitle("Test Subtitle");

Hide&show action bar on pre-honeycomb devices

The action bar can be shown even on pre-honeycomb devices, as shown via the actionbar-compat sample.
I want to be able to hide and show the action bar on demand (programmatically). How do I do that?
The problem is that getting the action bar using the support library returns null. I've also tried to find it using its id and set the visibility to gone, but it just showed a white space instead.
in the end i've used actionBarSherlock.
it has much more features and this requested feature is one of them. maybe the new support library works with this feature , but i've already moved to this solution.
ok , i have a workaround , but it doesn't work for the beginning , meaning that for a very short time , the actionbar will be shown on the beginning.
here's the code i've created to hide the action bar (for pre-honeycomb versions) ,which i've thought of by looking at this post :
ViewGroup decorView = (ViewGroup) this.getWindow().getDecorView();
ViewGroup root = (ViewGroup) decorView.getChildAt(0);
View titleContainer = root.getChildAt(0);
titleContainer.setVisibility(View.GONE);
if anyone knows how to make the action bar hidden on the beginning and choose when to show it , please let me know.
EDIT: btw, if anyone wishes to use a theme via the manifest and uses actionBarSherlock, you could use either "Theme.Sherlock.Light.NoActionBar" or "Theme.Sherlock.NoActionBar" , and if you wish to hide&show in code, simply use getSupportActionBar().hide() and getSupportActionBar().show().
Try this,hide action bar in xml by setting following property in xml for your activity.
`
<activity
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
Hope it helps if not then add a comment and if anything is wrong with my answer please correct me.

Categories

Resources