标签:android style blog http color io os 使用 ar
贴代码:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.frank.mobilesafe" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > </activity> <activity android:name=".SplashActivity" android:theme="@android:style/Theme.NoTitleBar" android:label="@string/title_activity_splash" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
处理类:
package com.frank.mobilesafe; import android.app.Activity; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; import android.view.Window; import android.widget.TextView; public class SplashActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏 setContentView(R.layout.activity_splash); TextView tv_version = (TextView) findViewById(R.id.tv_version); tv_version.setText(getVersion()); } protected String getVersion() { String versionStr = ""; PackageManager packManger = getPackageManager(); try { PackageInfo info = packManger.getPackageInfo(getPackageName(), 0); versionStr = info.versionName;//获得版本号 } catch (NameNotFoundException e) { // TODO Auto-generated catch block versionStr = ""; e.printStackTrace(); } return versionStr; } }
配置文件:
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > </activity> <activity android:name=".SplashActivity" android:theme="@android:style/Theme.NoTitleBar" android:label="@string/title_activity_splash" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application>
1、在设置splash画面显示的时候,最初以为是使用ImageView,最后了解才知道是使用的android:background="@drawable/luncher_bg"
2、新技术主要就是使用packmanger类读入关于版本的一些信息了
3、在去除标题的时候在配置文件中加入 android:theme="@android:style/Theme.NoTitleBar"之后程序在启动的时候就报错,最后看logcat顺着流程走才发现原来
Activity默认继承的是ActionBarActivity类,将其改为Activity则程序正常启动
标签:android style blog http color io os 使用 ar
原文地址:http://www.cnblogs.com/xuhongfei/p/3999131.html