搜索过很多实现方向,最后发现如下方式是一个简单、快捷的实现。
1、配置3个方面可实现
要求实现如下3个方向的配置:
AndoridManifest.xml中添加:
1、android:theme="@style/AppTheme"的AppTheme要求DarkActionBar,具体查看下面试验
2、android:parentActivityName 父亲Activity,就会在改Activity中出现:返回箭头;
3、android:label 用来在工具栏显示该activity的名称;如下图所示
android:theme="@style/AppTheme">
<activity
android:name=".testui.manutestui.ManuTestActivity"
android:parentActivityName=".testui.HomePageActivity"
android:label="SDK手动测试"
android:exported="false" />
<activity
android:name=".testui.autotestui.AutoTestActivity"
android:parentActivityName=".testui.HomePageActivity"
android:label="SDK自动测试"
android:exported="false" />
2、AppTheme主题设置的验证
1) 设置:windowTranslucentStatus(透明度)和DarkActionBar:
res/values/style.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
2) 设置DarkActionBar
没有设置透明度
去掉:<item name="android:windowTranslucentStatus">true</item>
3) 设置为NoActionBar ,无返回
res/values/style.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
亲自验证通过