date:2021-10-10 16:33:37

update:更新沉浸状态栏
This commit is contained in:
2021-10-10 16:35:28 +08:00
parent 588d815d7f
commit 0c1e0a094a
9 changed files with 51 additions and 19 deletions

View File

@@ -362,6 +362,8 @@ dependencies {
implementation 'com.trello.rxlifecycle2:rxlifecycle-android:2.2.2' implementation 'com.trello.rxlifecycle2:rxlifecycle-android:2.2.2'
implementation 'com.trello.rxlifecycle2:rxlifecycle-components:2.2.2' implementation 'com.trello.rxlifecycle2:rxlifecycle-components:2.2.2'
//状态栏透明 //状态栏透明
implementation 'com.gitee.zackratos:UltimateBarX:0.7.1'
// 基础依赖包,必须要依赖 // 基础依赖包,必须要依赖
implementation 'com.gyf.immersionbar:immersionbar:3.0.0' implementation 'com.gyf.immersionbar:immersionbar:3.0.0'
// fragment快速实现可选 // fragment快速实现可选

View File

@@ -28,6 +28,7 @@ import com.mjsheng.myappstore.utils.SPUtils;
import com.mjsheng.myappstore.utils.ServiceAliveUtils; import com.mjsheng.myappstore.utils.ServiceAliveUtils;
import com.mjsheng.myappstore.utils.StatusBarUtil; import com.mjsheng.myappstore.utils.StatusBarUtil;
import com.mjsheng.myappstore.utils.Utils; import com.mjsheng.myappstore.utils.Utils;
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
import cn.jpush.android.api.JPushInterface; import cn.jpush.android.api.JPushInterface;
@@ -41,6 +42,16 @@ public class HomeActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
StatusBarUtil.init(this); StatusBarUtil.init(this);
UltimateBarX.statusBar(this)
.transparent()
.colorRes(R.color.colorPrimaryDark)
.light(true)
.apply();
UltimateBarX.navigationBar(this)
.transparent()
.colorRes(R.color.colorPrimaryDark)
.light(true)
.apply();
setContentView(R.layout.activity_home); setContentView(R.layout.activity_home);
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
bt_log = findViewById(R.id.bt_log); bt_log = findViewById(R.id.bt_log);

View File

@@ -7,14 +7,27 @@ import android.view.View;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.gyf.immersionbar.ImmersionBar; import com.gyf.immersionbar.ImmersionBar;
import com.mjsheng.myappstore.R;
import com.mjsheng.myappstore.utils.StatusBarUtil; import com.mjsheng.myappstore.utils.StatusBarUtil;
import com.trello.rxlifecycle2.components.support.RxAppCompatActivity; import com.trello.rxlifecycle2.components.support.RxAppCompatActivity;
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
public abstract class BaseActivity extends RxAppCompatActivity { public abstract class BaseActivity extends RxAppCompatActivity {
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
StatusBarUtil.init(this); // StatusBarUtil.init(this);
UltimateBarX.statusBar(this)
.transparent()
.colorRes(R.color.colorPrimaryDark)
.light(true)
.apply();
UltimateBarX.navigationBar(this)
.transparent()
.colorRes(R.color.colorPrimaryDark)
.light(true)
.apply();
//状态栏改变放在setContentView前后有所不同
setContentView(this.getLayoutId()); setContentView(this.getLayoutId());
initView(); initView();
initData(); initData();

View File

@@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.mjsheng.myappstore.activity.HomeActivity"> tools:context="com.mjsheng.myappstore.activity.HomeActivity">
<ImageView <ImageView
@@ -36,6 +37,7 @@
app:layout_constraintEnd_toEndOf="@+id/bt_log" app:layout_constraintEnd_toEndOf="@+id/bt_log"
app:layout_constraintStart_toStartOf="@+id/bt_log" app:layout_constraintStart_toStartOf="@+id/bt_log"
app:layout_constraintTop_toBottomOf="@+id/bt_log" /> app:layout_constraintTop_toBottomOf="@+id/bt_log" />
<TextView <TextView
android:id="@+id/textView3" android:id="@+id/textView3"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@@ -5,6 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#ffffff" android:background="#ffffff"
android:fitsSystemWindows="true"
tools:context=".activity.MainActivity"> tools:context=".activity.MainActivity">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
@@ -165,8 +166,7 @@
android:textSize="@dimen/sp_12" android:textSize="@dimen/sp_12"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView2" app:layout_constraintStart_toEndOf="@+id/imageView2"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent" />
/>
<TextView <TextView
android:id="@+id/tv_devsn" android:id="@+id/tv_devsn"
@@ -240,8 +240,8 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="班级"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:text="班级"
android:textColor="#000000" android:textColor="#000000"
android:textSize="@dimen/sp_12" android:textSize="@dimen/sp_12"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@@ -281,8 +281,8 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="学号"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:text="学号"
android:textColor="#000000" android:textColor="#000000"
android:textSize="@dimen/sp_12" android:textSize="@dimen/sp_12"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@@ -322,8 +322,8 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="姓名"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:text="姓名"
android:textColor="#000000" android:textColor="#000000"
android:textSize="@dimen/sp_12" android:textSize="@dimen/sp_12"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@@ -363,8 +363,8 @@
android:id="@+id/textView4" android:id="@+id/textView4"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="版本"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:text="版本"
android:textColor="#000000" android:textColor="#000000"
android:textSize="@dimen/sp_12" android:textSize="@dimen/sp_12"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"

View File

@@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.mjsheng.myappstore.activity.HomeActivity"> tools:context="com.mjsheng.myappstore.activity.HomeActivity">
<ImageView <ImageView

View File

@@ -5,6 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#ffffff" android:background="#ffffff"
android:fitsSystemWindows="true"
tools:context=".activity.MainActivity"> tools:context=".activity.MainActivity">
@@ -21,8 +22,8 @@
android:id="@+id/back" android:id="@+id/back"
android:layout_width="@dimen/dp_16" android:layout_width="@dimen/dp_16"
android:layout_height="@dimen/dp_16" android:layout_height="@dimen/dp_16"
android:adjustViewBounds="true"
android:layout_marginLeft="4dp" android:layout_marginLeft="4dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:src="@drawable/back" android:src="@drawable/back"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@@ -136,8 +137,7 @@
android:textSize="@dimen/sp_12" android:textSize="@dimen/sp_12"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView2" app:layout_constraintStart_toEndOf="@+id/imageView2"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent" />
/>
<TextView <TextView
android:id="@+id/tv_devsn" android:id="@+id/tv_devsn"
@@ -211,8 +211,8 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="班级"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:text="班级"
android:textColor="#000000" android:textColor="#000000"
android:textSize="@dimen/sp_12" android:textSize="@dimen/sp_12"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@@ -252,8 +252,8 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="学号"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:text="学号"
android:textColor="#000000" android:textColor="#000000"
android:textSize="@dimen/sp_12" android:textSize="@dimen/sp_12"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@@ -293,8 +293,8 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="姓名"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:text="姓名"
android:textColor="#000000" android:textColor="#000000"
android:textSize="@dimen/sp_12" android:textSize="@dimen/sp_12"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@@ -334,8 +334,8 @@
android:id="@+id/textView4" android:id="@+id/textView4"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="版本"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:text="版本"
android:textColor="#000000" android:textColor="#000000"
android:textSize="@dimen/sp_12" android:textSize="@dimen/sp_12"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@@ -355,7 +355,6 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout> </LinearLayout>
<Button <Button
@@ -377,9 +376,9 @@
<TextView <TextView
android:id="@+id/tv_customversion" android:id="@+id/tv_customversion"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp" android:layout_marginRight="10dp"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
android:layout_height="wrap_content"
android:textColor="@color/background_top" android:textColor="@color/background_top"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" /> app:layout_constraintEnd_toEndOf="parent" />

View File

@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="colorPrimary">#3F51B5</color> <color name="colorPrimary">#FFFFFF</color>
<color name="colorPrimaryDark">#303F9F</color> <color name="colorPrimaryDark">#FFFFFF</color>
<color name="colorAccent">#FF4081</color> <color name="colorAccent">#FFFFFF</color>
<!-- <color name="colorPrimary">#3F51B5</color>-->
<!-- <color name="colorPrimaryDark">#303F9F</color>-->
<!-- <color name="colorAccent">#FF4081</color>-->
<color name="textColor">#ff797979</color> <color name="textColor">#ff797979</color>
<color name="topcolor">#878686</color> <color name="topcolor">#878686</color>
<color name="white">#ffffff</color> <color name="white">#ffffff</color>

View File

@@ -6,6 +6,7 @@
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
<item name="android:windowBackground">@color/colorPrimary</item>
</style> </style>
<style name="password_dialog_style"> <style name="password_dialog_style">