About full screen and untitle bar

Source: Internet
Author: User

Remove the title bar: the first method: [java] <span style = "font-size: 14px;"> requestWindowFeature (Window. FEATURE_NO_TITLE); // remove the title bar </span> note that this sentence must be written before the setContentView () method. Otherwise, the second error will be reported: In AndroidManifest. the xml file defines [html] view plaincopy <span style = "font-size: 14px;"> <application android: icon = "@ drawable/icon" android: label = "@ string/app_name" android: theme = "@ android: style/Theme. noTitleBar "> </span> it can be seen that, in this case, the entire application will remove the title bar. If you only want If you remove the title bar of an Activity, you can add this attribute to the activity tag. The third type is not commonly used in general applications. It is to create a style under the res/values directory. xml files, such as [html] <span style = "font-size: 14px;" ><? Xml version = "1.0" encoding = "UTF-8"?> <Resources> <style name = "notitle"> <item name = "android: windowNoTitle"> true </item> </style> </resources> </span>, we have customized a style, which is equivalent to a topic, and then in AndroidManifest. the xml file defines [html] <application android: icon = "@ drawable/icon" android: label = "@ string/app_name" android: theme = "@ style/notitle"> in this way, you can also remove the title bar. Three Methods to remove the title bar are described as the first method. Sometimes we can see that the title bar appears first, then disappear, because we only defined it in the oncreate method of the activity. The second method is better than the first one, so it won't happen. The third one is my best feeling, In this way, the functions are separated to facilitate maintenance and extended full screen: the first [html] <span style = "font-size: 14px;"> getWindow (). setFlags (WindowManager. layoutParams. FLAG_FULLSCREEN, WindowManager. layoutParams. FLAG_FULLSCREEN); </span> type 2 [html] <span style = "font-size: 14px;"> android: theme = "@ android: style/Theme. noTitleBar. fullscreen "</span> [html] <span style =" font-size: 14px; "> application android: icon =" @ drawable/icon "android: label = "@ string/app_name" Droid: theme = "@ style/fullscreem" </span> there are other settings for the title bar: 1. Hide the title bar requestWindowFeature (Window. FEATURE_NO_TITLE); 2. display the progress bar requestWindowFeature (Window. FEATURE_PROGRESS); setContentView (R. layout. progressbar_1); setProgressBarVisibility (true); final ProgressBar progressHorizontal = (ProgressBar) findViewById (R. id. progress_horizontal); setProgress (progressHorizontal. getProgress () * 100); setSecondaryProgress (ProgressHorizontal. getSecondaryProgress () * 100); 3. Use the custom title bar requestWindowFeature (Window. FEATURE_CUSTOM_TITLE); setContentView (R. layout. xxx); getWindow (). setFeatureInt (Window. FEATURE_CUSTOM_TITLE, R. layout. my_title_bar); 4. Clear the title bar content, while the area is retained (ViewGroup) getWindow (). findViewById (com. android. internal. r. id. title_container )). removeAllViews (); 5. Hide the title bar (ViewGroup) getWindow (). findViewById (com. android. internal. R. Id. title_container )). setVisibility (View. GONE); 6. display the title bar... setVisibility (View. VISIBLE); other considerations (1) requestWindowFeature () should be called before setContentView (); (2) set various Feature, which is exclusive. Once set, it cannot be changed to another type. (3) When TabHost (derived from ActivityGroup) is used, the activities in each Tab are either NO_TITLE or CUSTOM_TITLE, and cannot be set separately. Remove the title bar: the first method: [java] <span style = "font-size: 14px;"> requestWindowFeature (Window. FEATURE_NO_TITLE); // remove the title bar </span> note that this sentence must be written before the setContentView () method. Otherwise, the second error will be reported: In AndroidManifest. the xml file defines [html] view plaincopy <span style = "font-size: 14px;"> <application android: icon = "@ drawable/icon" android: label = "@ string/app_name" android: theme = "@ android: style/Theme. noTitleBar "> </span> we can see that, in this case, the entire application will remove the title bar. To remove the title bar of an Activity, you can add this attribute to the activity tag. The third type is not commonly used in general applications. You can create a style under the res/values directory. xml files, such as [html] <span style = "font-size: 14px;" ><? Xml version = "1.0" encoding = "UTF-8"?> <Resources> <style name = "notitle"> <item name = "android: windowNoTitle"> true </item> </style> </resources> </span>, we have customized a style, which is equivalent to a topic, and then in AndroidManifest. the xml file defines [html] <application android: icon = "@ drawable/icon" android: label = "@ string/app_name" android: theme = "@ style/notitle"> in this way, you can also remove the title bar. Three Methods to remove the title bar are described as the first method. Sometimes we can see that the title bar appears first, then disappear, because we only defined it in the oncreate method of the activity. The second method is better than the first one, so it won't happen. The third one is my best feeling, In this way, the functions are separated to facilitate maintenance and extended full screen: the first [html] <span style = "font-size: 14px;"> getWindow (). setFlags (WindowManager. layoutParams. FLAG_FULLSCREEN, WindowManager. layoutParams. FLAG_FULLSCREEN); </span> type 2 [html] <span style = "font-size: 14px;"> android: theme = "@ android: style/Theme. noTitleBar. fullscreen "</span> [html] <span style =" font-size: 14px; "> application android: icon =" @ drawable/icon "android: label = "@ string/app_name" Droid: theme = "@ style/fullscreem" </span> there are other settings for the title bar: 1. Hide the title bar requestWindowFeature (Window. FEATURE_NO_TITLE); 2. display the progress bar requestWindowFeature (Window. FEATURE_PROGRESS); setContentView (R. layout. progressbar_1); setProgressBarVisibility (true); final ProgressBar progressHorizontal = (ProgressBar) findViewById (R. id. progress_horizontal); setProgress (progressHorizontal. getProgress () * 100); setSecondaryProgress (ProgressHorizontal. getSecondaryProgress () * 100); 3. Use the custom title bar requestWindowFeature (Window. FEATURE_CUSTOM_TITLE); setContentView (R. layout. xxx); getWindow (). setFeatureInt (Window. FEATURE_CUSTOM_TITLE, R. layout. my_title_bar); 4. Clear the title bar content, while the area is retained (ViewGroup) getWindow (). findViewById (com. android. internal. r. id. title_container )). removeAllViews (); 5. Hide the title bar (ViewGroup) getWindow (). findViewById (com. android. internal. R. Id. title_container )). setVisibility (View. GONE); 6. display the title bar... setVisibility (View. VISIBLE); other considerations (1) requestWindowFeature () should be called before setContentView (); (2) set various Feature, which is exclusive. Once set, it cannot be changed to another type. (3) When TabHost (derived from ActivityGroup) is used, the activities in each Tab are either NO_TITLE or CUSTOM_TITLE, and cannot be set separately.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.