I am using the following code to dynamically hide the TitleBar:

          ViewGroup ob = (ViewGroup) 
findViewById(android.R.id.title).getParent();
          ((View)ob).setVisibility(View.INVISIBLE);
          ob.setLayoutParams(new LinearLayout.LayoutParams(0, 0));
          getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
          
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
          findViewById(android.R.id.content).getRootView().requestLayout();

I am then using the following code to dynamically show the TitleBar:

          ViewGroup ob = (ViewGroup) 
findViewById(android.R.id.title).getParent();
          ((View) ob).setLayoutParams(new 
LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 
LayoutParams.WRAP_CONTENT));
          ((View)ob).setVisibility(View.VISIBLE);
          
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
          
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
          findViewById(android.R.id.content).getRootView().requestLayout();

This code works on the emulator (using 2.2 and 4.0.3) as well as on a 
device (Motorola Droid running Cyanogenmod 7) with no problems. 
I'm nervous though about using the android.R.id.title in such a way since 
there is no documentation on the title field in android.R.id. Also, all the 
questions/answers/blog posts I found on the internet say that there is now 
way to dynamically remove the title bar after setContentView is called; so 
I'm assuming the method I'm using above is incorrect in some way. 
Is what I am doing safe?

Thanks,
Vance

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to