(The one day)About Android 系统状态栏与APP主题颜色一致(方法一)

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


但是以上方法可能达不到想要的效果,实用效果参考下一篇文章

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值