如何全屏制作活动?我的意思是没有通知栏.有任何想法吗?
我需要在我的蜂窝应用程序中实现启动画面.我在activity的onCreate中使用此代码来显示splash:
setContentView(R.layout.splash);
getActionBar().hide();
Run Code Online (Sandbox Code Playgroud)
并且此代码在某段时间后显示主UI:
setContentView(R.layout.main);
getActionBar().show();
Run Code Online (Sandbox Code Playgroud)
但是在调用onCreate并且出现splash 之前,显示操作栏时会有少量时间.
如何让动作栏隐形?
我尝试将主题应用于没有操作栏的活动:
<item name="android:windowActionBar">false</item>
Run Code Online (Sandbox Code Playgroud)
但在这种情况下getActionBar()总是返回null,我发现无法再显示它.
我正在尝试在我的项目中使用MaterialDesign,但我一直都会收到此错误:
Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features: { windowActionBar: false, windowActionBarOverlay: false, android:windowIsFloating: false, windowActionModeOverlay: false, windowNoTitle: false }
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:371)
at android.support.v7.app.AppCompatDelegateImplV7.initWindowDecorActionBar(AppCompatDelegateImplV7.java:173)
at android.support.v7.app.AppCompatDelegateImplBase.getSupportActionBar(AppCompatDelegateImplBase.java:87)
at android.support.v7.app.AppCompatDelegateImplV7.setSupportActionBar(AppCompatDelegateImplV7.java:197)
at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:99)
at de.memorian.playpal.MainActivity.afterInject(MainActivity.java:72)
Run Code Online (Sandbox Code Playgroud)
我已经解决了类似的问题,但每次我都遇到同样的错误.
MainActivity.java:
@EActivity(R.layout.activity_main)
public class MainActivity extends AppCompatActivity {
@ViewById
protected Toolbar toolbar;
@AfterInject
public void afterInject() {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
}
Run Code Online (Sandbox Code Playgroud)
styles.xml:
<style name="AppTheme" parent="AppTheme.Base"/>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
款式 - v21.xml:
style …Run Code Online (Sandbox Code Playgroud) 
当我的应用程序启动时,我想隐藏软键栏(红色矩形)以拥有更大的屏幕.
我怎么能隐藏它?
当应用程序退出时,我是否需要故意显示该栏?或者它会在应用程序退出后自动恢复?
Android 4.1,手机正面没有硬件按键.
我想让我的活动全屏显示状态栏,就像这张图片一样:
我在manifest内部activity标记中使用了此代码:
'android:theme="@style/Theme.AppCompat.Light.NoActionBar"'
Run Code Online (Sandbox Code Playgroud)
但我的观点并不是从状态栏开始的,它看起来像这样:
我怎样才能让自己activity看起来像第一个?
android android-theme android-activity android-fullscreen android-statusbar
我在Android Studio中创建了一个Android应用程序,它默认创建了这些样式:
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但是,在一个活动中,我尝试将其设置为主题:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
...
android:theme="@style/AppTheme.NoActionBar">
Run Code Online (Sandbox Code Playgroud)
但是当我运行应用程序时,我正在获取操作栏:
我为什么要一个行动吧?我做了一些明显错误的事情,还是Android工作室,这是谷歌自己平台的官方IDE,试图混淆/误导其开发者?
这是我的活动代码,其中没有任何内容可以导致操作栏自行显示:
public class WelcomeActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
setContentView(R.layout.activity_welcome);
}
}
Run Code Online (Sandbox Code Playgroud) 我想创建一个全屏活动.上面没有像Notification Bar那样的东西,下面没有像Home-Button那样的东西.我能够得到这个,但也想删除下面的主页按钮栏:
这是我的代码.
<style name="MyScreen" parent="@style/Theme.AppCompat.Light">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
Run Code Online (Sandbox Code Playgroud) android android-layout android-view android-activity android-fullscreen
我试图禁用我的一些活动的操作栏,但无论我尝试什么,我似乎无法删除它.
在我的styles.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>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
Run Code Online (Sandbox Code Playgroud)
在我的manifest.xml中,我有:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".NewActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
</activity>
</application>
Run Code Online (Sandbox Code Playgroud)
我的活动布局文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_new"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
我的app_bar_new布局文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" …Run Code Online (Sandbox Code Playgroud) 我想隐藏默认操作栏,因此在清单文件中我有以下代码:
<style name="Theme.MyCompose" parent="Theme.Material.DayNight.NoActionBar">
</style>
<style name="Theme.Material.DayNight.NoActionBar" parent="@android:style/Theme.Material.Light.NoActionBar" />
Run Code Online (Sandbox Code Playgroud)
而效果是这样的:
我想要实现的目标是这样的:
摄影应覆盖白色区域。如何做到这一点?
更新1
在实施具有半透明状态栏和伴奏插图支持的解决方案后,我遇到了奇怪的行为。当窗口标志设置如下时:
window.setFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
)
Run Code Online (Sandbox Code Playgroud)
当删除这些标志时,插图可以工作,但我有那个阴影:
android user-experience kotlin android-actionbar android-jetpack-compose
如何动态隐藏状态和导航栏彻底?
该应用程序包含一个带有应用栏/工具栏和 FAB 按钮的常规导航抽屉。
当切换到全屏模式,在内容的导航和状态栏的滚动了。屏幕上留下两个空条。我想要隐藏那些空条。
我创建了一个最小的演示应用程序。左侧是常规应用程序。当推动晶圆厂时,应用程序应该全屏显示。
我怎样才能让酒吧隐藏?
问题:请写出最小演示项目中需要哪些更改?
更新了第二个解决方案:
@Roaim 提供的 GREAT 解决方案有效。必要的是将android:fitsSystemWindows布局属性设置为 false。
如果您仍然无法显示和隐藏状态/导航栏,此解决方案可能会对您有所帮助。
完全隐藏条形:
public static void hideSystemUI() {
if (getSupportActionBar() != null) {
getSupportActionBar().hide();
}
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN);
}
Run Code Online (Sandbox Code Playgroud)
并显示所有条:
public static void showSystemUI() {
if (getSupportActionBar() != null) {
getSupportActionBar().show();
}
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
}
Run Code Online (Sandbox Code Playgroud) android-layout android-actionbar android-fullscreen android-statusbar android-navigation-bar