android透明状态栏
来源:互联网 发布:市场营销书籍推荐知乎 编辑:程序博客网 时间:2024/04/30 08:53
1、添加依赖
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
2、
package com.deepblue.testsharedemo;import android.graphics.Color;import android.os.Build;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.Window;import android.view.WindowManager;import com.readystatesoftware.systembartint.SystemBarTintManager;public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /** * 全屏(必须在setContentView之前调用) * requestFeature() must be called before adding content */ requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏 /** * 加载布局 */ setContentView(R.layout.activity_main); /** * 隐藏titlebar(必须是有titlebar的主题) */// getSupportActionBar().hide(); initWidget(); } private void initWidget() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //透明状态栏 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); //透明导航栏 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); }// create our manager instance after the content view is set SystemBarTintManager tintManager = new SystemBarTintManager(this); // enable status bar tint tintManager.setStatusBarTintEnabled(true); // enable navigation bar tint tintManager.setNavigationBarTintEnabled(true); // // set a custom tint color for all system bars tintManager.setTintColor(Color.GREEN);/** * set a custom navigation bar resource */// tintManager.setNavigationBarTintResource(R.mipmap.ic_launcher);/** * set a custom status bar drawable */// tintManager.setNavigationBarTintDrawable(Drawable); }}
3、在使用的activity的xml中要设置
android:fitsSystemWindows="true"
<?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" android:fitsSystemWindows="true"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="hello world" /></RelativeLayout>
4、application的配置中要设置
android:windowTranslucentNavigation="true"
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppNoBarTheme" android:windowTranslucentNavigation="true"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application>5、附上第三方的github地址
https://github.com/jgilfelt/SystemBarTint
1 0
- android 透明状态栏,沉浸状态栏
- Android状态栏着色-透明状态栏
- Android 透明状态栏实现
- android 全透明状态栏
- 设置android 状态栏透明
- Android 状态栏透明
- android透明状态栏
- android沉浸(透明状态栏)
- android状态栏透明
- android 全透明状态栏
- android 状态栏全透明
- android设置状态栏透明
- android透明状态栏
- Android实现透明状态栏
- Android沉浸(透明状态栏)
- android透明状态栏
- Android透明状态栏
- Android透明状态栏
- 基于iOS平台配置免费离线语音识别功能-OpenEars
- Struts2的Action访问Servlet API的方式
- Problem J
- CSS3 overflow-y 与overflow-y属性
- Echarts树图结构中图例的选择显示功能实现
- android透明状态栏
- 华为机试题--9.数字颠倒
- c++ 控制台弹出文件管理对话框
- android设计模式之装饰模式(二)
- OPENGL ES常用函数功能总结
- lua协同程序实现管道过滤器
- cocos2dx-CCSpriteBatchNode源码分析(VAO+VBO)
- 动态规划——收集样本机器人问题
- hrbust 1359 Leyni的国家II【树状dp】