Android杂谈——启动页面和框口全屏设置
来源:互联网 发布:用什么能代替淘宝指数 编辑:程序博客网 时间:2024/06/05 01:00
这里用两种方式实现应用的启动页面:
1,使用Handler的postDelayed(runnable, delayTime)方法:
将runnable对象加入handler queue,当经过delayTime后,runnable会运行在handler所绑定的线程上。
2,使用定时器:
package com.example.demo;import java.util.Timer;import java.util.TimerTask;import android.app.Activity;import android.content.Intent;import android.os.Bundle;public class WelcomeActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.welcom_layout); welcom(); } private void welcom() { /*new Handler().postDelayed(new Runnable() { @Override public void run() { Intent mainIntent = new Intent(getApplicationContext(), MainActivity.class); startActivity(mainIntent); WelcomeActivity.this.finish(); } }, 2000);*/ new Timer().schedule(new TimerTask() { @Override public void run() { Intent mainIntent = new Intent(getApplicationContext(), MainActivity.class); startActivity(mainIntent); WelcomeActivity.this.finish(); } }, 2000); }}
这里只是用了一张图片作为应用的启动画面,当然想要做得更炫的话,可以用动画之类的:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/huoying" /></RelativeLayout>
启动之后的应用主界面:
package com.example.demo;import android.app.Activity;import android.os.Bundle;public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); }}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:text="@string/hello_world" /></LinearLayout>
在manifest中,我们设置了activity 的 android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"属性,这样这个欢迎页面就会全屏显示:
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.demo" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.demo.MainActivity" android:label="@string/app_name" > </activity> <activity android:name="com.example.demo.WelcomeActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application></manifest>
下面再说一下界面全屏的设置方法:
1,在manifest中设置activity / application 的 android:theme属性:
设置为:@android:style/Theme.Black.NoTitleBar 这样并非是全屏,但是不会显示actionBar;
设置为:@android:style/Theme.Black.NoTitleBar.Fullscreen 这样就会全屏显示
(还可以设置:android:screenOrientation="landscape" 屏幕就会横屏显示了)
2,在代码中设置:
//不显示ActionBar requestWindowFeature(Window.FEATURE_NO_TITLE); //不显示系统的通知栏()全屏 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
一定要记住要在setContentView()之前设置窗口的信息。
- Android杂谈——启动页面和框口全屏设置
- 软件启动页面全屏设置
- Android 设置秒开全屏启动屏
- AS中启动页面设置全屏无效解决办法
- 设置页面全屏
- Android启动页面设置Splash
- android 启动页面的设置
- Android设置Activity全屏和无标题
- Android全屏和强制横屏竖屏设置
- android 去标题和设置全屏
- Android 设置全屏和无标题模式
- Android设置Activity全屏和无标题
- android界面无标题和全屏设置
- android-设置全屏,去除状态栏和标题栏
- android设置全屏和去掉状态栏
- Android Activity全屏和设置背景色
- android设置全屏和横屏
- Android 全屏设置和禁止横屏竖屏切换
- Android 启动程序时动画效果
- DIRECTORY_SEPARATOR
- Bigcommerce:Check Out页面的一些参数获取(比如国家)
- poj 1743 Musical Theme(不可重叠的最长重复子串,后缀数组)
- 数据库中字符集不匹配报错
- Android杂谈——启动页面和框口全屏设置
- Web 通信 之 长连接、长轮询(long polling)
- hadoop 9000端口不通判断
- ie6,ie7,ie8 css bug兼容解决方法集合
- 彩商网成立
- 网络学习笔记_WLAN
- mahout算法集
- start.s 代码分析
- 求无序数组中第二小的元素