2013年8月12日星期一

android commonly used code snippets finishing constantly updated

 

1, how to make android without title bar ?

 

(1) @ @ in AndroidManifest.xml set the theme of ways to achieve the following snippet :

 
  
<application android:theme="@android:style/Theme.NoTitleBar" android:label="@string/app_name" android:icon="@drawable/icon_notitle"> 
...
...
</application>
 
 

PS: The above code set is implemented throughout the project with no title bar , if you just want a certain activity without a title , you can in a single activity set android: theme = "@ android: style / Theme.NoTitleBar" to .

 

(2) @ @ in code :

 
  
requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
 
 

PS: This code must be set at setContentView () method of the front , otherwise it will error . When you run the program will find the title bar will show began , and then disappear, because the title bar is to be executed in oncreate , the beginning of the title bar will be displayed , if not completely display the title bar , the use of methods ( a ) better.

 

 

2, how to make the page full screen ?

 

(1) xml implemented , the code is as follows :

 
  
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
 
 

(2) code :

 
  
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
 
 

没有评论:

发表评论