我提到了这个link。在这种情况下,如果用户单击EditText(例如,To To),则会弹出键盘,同时用户可以滚动查看所有剩余的视图(例如:compose,subject,send按钮)。该屏幕。同样,在我的应用程序中,我有一个活动,就是我有一些小部件或视图。假设如果用户单击“活动”中的Edittext,则弹出键盘,并且我可以滚动查看其余视图。但是,如果我在清单中给该属性android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
,则无法滚动以查看其余视图,但是如果在清单中给该属性android:theme="@android:style/Theme.NoTitleBar"
,则可以滚动以查看剩余视图,但该屏幕上有状态栏,在这里,我希望全屏显示,即使弹出键盘,也可以滚动查看其余视图。为此,我必须进行哪些更改。?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
在此处检查文档:https://developer.android.com/training/system-ui/status.html并且您的应用将进入全屏模式。没有状态栏,没有标题栏。 :)
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
隐藏操作栏,请写这行:-
requestWindowFeature(Window.FEATURE_NO_TITLE);
这两行都可以一起编写以隐藏操作栏和状态栏。所有这些行都必须在setContentView
方法中调用onCreate
方法之前编写。
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
<resources>
<!-- Base application theme. -->
<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="HiddenTitleTheme" parent="AppTheme">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
就像这样在清单中调用此android:theme="@style/HiddenTitleTheme"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
//this is for hiding action bar
并且在MainActivity.java中-> onCreate()方法中,添加以下内容:
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); //this is for hiding status bar
请看一下:
https://developer.android.com/training/system-ui/status.html
xml将状态栏的颜色设置为透明来隐藏状态栏。将statusBarColor项目添加到您的活动主题:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
解决方案相当大,所以这是SO的链接:
StackOverflow : Hide status bar in android 4.4+ or kitkat with Fullscreen
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= 19) {
getWindow().setFlags(AccessibilityNodeInfoCompat.ACTION_NEXT_HTML_ELEMENT, AccessibilityNodeInfoCompat.ACTION_NEXT_HTML_ELEMENT);
getWindow().getDecorView().setSystemUiVisibility(3328);
}else{
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
DataBindingUtil.setContentView(this, R.layout.activity_hse_video_details);
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// If the Android version is lower than Jellybean, use this call to hide
// the status bar.
if (Build.VERSION.SDK_INT < 16) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
ActionBar actionBar = getActionBar();
actionBar.hide();
}
setContentView(R.layout.activity_main);
}
...
}
Manifest
中使用android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen"
if (Build.VERSION.SDK_INT < 16) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
ActionBar actionBar = getActionBar();
actionBar.hide();
}
在
样式身体标签粘贴内部
<item name="android:windowTranslucentStatus" tools:targetApi="kitkat">true</item>
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(R.style.Theme_AppCompat_Light_NoActionBar);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN
, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity__splash_screen);
}
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
"Theme.NoTitleBar.Fullscreen"
,并尝试为"android:windowSoftInputMode=adjustResize"
中的活动设置AndroidManifest.xml.
。您可以找到详细信息here。requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.your_screen);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
// some your code
}
Activity
。@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
void hideStatusBar() {
if (Build.VERSION.SDK_INT < 16) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
}
您可以使用此方法隐藏状态栏。这对于隐藏操作栏也很重要。在这种情况下,如果您已从支持库(如Appcompat)扩展了活动,则可以getSupportActionBar()。hide(),也可以在上述方法之后简单地调用getActionBar()。hide()。谢谢
manifest.xml
文件中更改应用程序的主题。android:theme="@android:style/Theme.Translucent.NoTitleBar"
使用此代码:
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.youractivityxmlname);