发布于 2017-10-03 10:36:31 | 260 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

Android移动端操作系统

Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。尚未有统一中文名称,中国大陆地区较多人使用“安卓”或“安致”。


本篇文章主要介绍了Android 全屏显示和无标题栏的方法,并附上代码实例,和运行效果图,有需要的朋友可以参考下

在Android实现没有标题栏的方法有两种:

在代码中添加


requestWindowFeature(Window.FEATURE_NO_TITLE); 

在清单文件AndroidManifest.xml中添加


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

具体的代码如下:

第一种:


MainActivity.java
package com.lingdududu.test; 
 
import android.app.Activity; 
import android.os.Bundle; 
import android.view.Window; 
 
public class MainActivity extends Activity { 
 /** Called when the activity is first created. */ 
 private boolean catchHomeKey = false; 
 public void onCreate(Bundle savedInstanceState) { 
 super.onCreate(savedInstanceState); 
 this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
 setContentView(R.layout.main); 
  
 } 
} 

第二种:


AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
 package="com.lingdududu.test" 
 android:versionCode="1" 
 android:versionName="1.0"> 
 <uses-sdk android:minSdkVersion="10" /> 
 
 <application android:icon="@drawable/icon" android:label="@string/app_name"> 
 <activity android:name=".MainActivity" 
   android:label="@string/app_name" 
   android:theme="@android:style/Theme.NoTitleBar" > 
  <intent-filter> 
  <action android:name="android.intent.action.MAIN" /> 
  <category android:name="android.intent.category.LAUNCHER" /> 
  </intent-filter> 
 </activity> 
 
 </application> 
</manifest> 

效果图:

如果想让窗口全屏显示:

将下面两段代码分别替换上面的两段设置无标题的代码就可以了


getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN ,   
  WindowManager.LayoutParams. FLAG_FULLSCREEN); 
 
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 

效果图:

 以上就是对Android 全屏效果的代码实例,和效果显示,希望能帮助到大家。



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务