android - AppComp的全屏主题
我想知道如何将全屏主题(没有标题栏+没有操作栏)应用于某个活动。 我正在使用支持包v7中的AppCompat库。
我试图将android:theme="@android:style/Theme.NoTitleBar.Fullscreen"应用于我的具体活动,但它崩溃了。 我认为这是因为我的应用程序主题是这样的。
我也尝试过这个
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
它只隐藏标题栏但不隐藏操作栏。我目前的解决方法是隐藏动作栏
getSupportActionBar().hide();
15个解决方案
747 votes
在应用程序中使用Theme.AppCompat时,可以通过将下面的代码添加到样式中来使用FullScreenTheme。
true
false
true
@null
并在您的清单文件中提及。
android:name=".activities.FullViewActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"
/>
nebyan answered 2019-02-11T09:28:09Z
61 votes
基于@nebyan的回答,我发现操作栏仍然没有隐藏。
以下代码适用于我:
true
false
true
@null
当然不要忘记编辑您的AndroidManifest文件。
android:name="YOUR_ACTIVITY_NAME"
android:theme="@style/AppFullScreenTheme"
/>
Hover Ruan answered 2019-02-11T09:28:49Z
15 votes
true
true
使用style.xml中的上述xml,您将能够隐藏标题和操作栏。
Dharmendra Pratap Singh answered 2019-02-11T09:29:16Z
9 votes
Android 4.0之前和之后版本(API级别14)出现问题。
从这里[https://developer.android.com/training/system-ui/status.html]我创建了自己的解决方案..
@SuppressLint("NewApi")
@Override
protected void onResume()
{
super.onResume();
if (Build.VERSION.SDK_INT < 16)
{
// Hide the status bar
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
// Hide the action bar
getSupportActionBar().hide();
}
else
{
// Hide the status bar
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
/ Hide the action bar
getActionBar().hide();
}
}
我在onResume()方法中编写此代码,因为如果您退出应用程序然后重新打开它,操作栏将保持活动状态! (所以这解决了问题)
我希望它有用;)
KrhashisM answered 2019-02-11T09:30:03Z
6 votes
你的“解决方法”(自己隐藏actionBar)是正常的方法。 但谷歌建议在隐藏TitleBar时始终隐藏ActionBar。 看看这里:[https://developer.android.com/training/system-ui/status.html]
Simulant answered 2019-02-11T09:30:28Z
6 votes
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//to remove "information bar" above the action bar
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
//to remove the action bar (title bar)
getSupportActionBar().hide();
}
Shuyan Ji answered 2019-02-11T09:30:46Z
4 votes
您可以按照以下步骤操作: -
AndroidManifest.xml中
android:name=".ui.FullImageActivity"
android:label="@string/title_activity_main"
android:screenOrientation="landscape"
android:theme="@style/DialogTheme">
Style.xml
fill_parent
fill_parent
false
true
false
FullImageActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
setContentView(R.layout.image_view);
}
我希望它会有所帮助。谢谢!!
jagdish answered 2019-02-11T09:31:37Z
2 votes
它应该是parent =“@ style / Theme.AppCompat.Light.NoActionBar”
true
false
true
@null
vntstudy answered 2019-02-11T09:32:02Z
1 votes
requestWindowFeature(Window.FEATURE_NO_TITLE);
prashantwosti answered 2019-02-11T09:32:21Z
0 votes
要删除AppCompat中的标题栏:
@Override
protected void onCreate(Bundle savedInstanceState) {
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
}
Andoctorey answered 2019-02-11T09:32:46Z
0 votes
true
false
true
@null
Matt Barrera answered 2019-02-11T09:33:04Z
0 votes
只是这个 ?
true
Xan answered 2019-02-11T09:33:29Z
0 votes
此主题仅适用于API 21(包含)之后。 并使状态栏和导航栏都透明。
false
true
@android:color/transparent
@android:color/transparent
@android:color/transparent
true
@null
DysaniazzZ answered 2019-02-11T09:33:54Z
0 votes
简单地说这个家伙你的风格:
true
false
true
@null
Reza Hamzehie answered 2019-02-11T09:34:19Z
0 votes
要隐藏状态栏和操作栏并使您的活动全屏显示,请在活动的onResume()或onWindowFocusChanged()方法中使用以下代码:
@Override
protected void onResume() {
super.onResume();
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| 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);
}
您可以在以下链接中找到更多信息:
[https://developer.android.com/training/system-ui/immersive#EnableFullscreen]
全屏无导航&amp; 状态栏
如何隐藏Android手机上的软键栏?
注意:在此线程中使用xml解决方案我只能隐藏状态栏而不能隐藏导航栏。
Darush answered 2019-02-11T09:35:20Z