直播系统源码,android 全透明式状态栏
直播系统源码,android 全透明式状态栏实现的相关代码
```handlebars if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){ //半透明头部状态栏 布局在状态栏下方 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } ```
在各种尝试之后,终于找到了下面这种方法,这个只试用于5.0
```handlebars if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); } ```
Build.VERSION_CODES.LOLLIPOP:5.0
```handlebars public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){//4.4 全透明状态栏 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//5.0 全透明实现 Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT);//calculateStatusColor(Color.WHITE, (int) alphaValue) } } } ``` ```handlebars <?xml version="1.0" encoding="utf-8"?> <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" tools:context="com.yqy.yqy_test.MainActivity"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#ffe0a0" android:fitsSystemWindows="true" android:clipToPadding="true" android:gravity="center" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="我是标题"/> </LinearLayout> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:text="我是内容" android:gravity="center" android:background="#e0ffa0"/> </LinearLayout> ```
以上就是直播系统源码,android 全透明式状态栏实现的相关代码, 更多内容欢迎关注之后的文章