Android 4.4 以上系统设置状态栏一体化
参照( http://www.2cto.com/kf/201503/381348.html )
1、要在Android的AndroidMainfest.xml文件下声明
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
<activity
android:name="com.ycf.systemstatus.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
2.加载nineoldandroids-2.4.0.jar
3.实现类:把状态栏背景设为全透明。
public
class
MainActivity extends
Activity{ @Override protected
void
onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTranslucentStatus();
//此方法要写在setContentView前面 setContentView(R.layout.activity_main); } /** *
设置状态栏背景状态 */ private
void
setTranslucentStatus() { if
(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Window
win = getWindow(); WindowManager.LayoutParams
winParams = win.getAttributes(); final
int
bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; winParams.flags
|= bits; win.setAttributes(winParams); } SystemStatusManager
tintManager = new
SystemStatusManager(this); tintManager.setStatusBarTintEnabled(true);
//激活状态栏 tintManager.setStatusBarTintResource(0);//状态栏无背景//tintManager.setStatusBarTintColor(Color.rgb(255,160,00));
//设置其状态栏颜色,可以使用//tintManager.setStatusBarTintDrawable(getResources().getDrawable(R.drawable.bg));//使用Drawable资源
}}以上相关资源的下载地址http://download.youkuaiyun.com/detail/cs_leebo/9166139
但是以上方法可能达不到想要的效果,实用效果参考下一篇文章
设置Android4.4以上系统状态栏一体化教程
本文提供了一种在Android4.4及以上系统中设置状态栏一体化的方法,包括在AndroidManifest.xml文件中声明,加载nineoldandroids库,并通过自定义类实现状态栏背景设置为全透明。
70

被折叠的 条评论
为什么被折叠?



