问题
I referred this link. In that if the user clicks on EditText(for ex To: ) at that time keyboard will be popped out and at the same time the user can be able to scroll to see all remaining views(ex: compose,subject, send button) in that screen. Similarly in my app I have one activity in that I am having some widgets or views.
Suppose if the user clicks on Edittext which is in my Activity then keyboard is popping out and i can be able to scroll to see remaining views. But if i give this attribute android:theme=\"@android:style/Theme.NoTitleBar.Fullscreen\"
in manifest i was unable to scroll to see remaining views but if give attribute android:theme=\"@android:style/Theme.NoTitleBar\"
like this in manifest I can be able to scroll to see remaining view but there is status bar in that screen, here I want full screen and even if the keyboard is popped out I can scroll to see remaining views..? what changes I have to made for this..?
回答1:
Write this in your Activity
@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);
}
Check Doc here : https://developer.android.com/training/system-ui/status.html
and your app will go fullscreen. no status bar, no title bar. :)
回答2:
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();
}
回答3:
Use theme "Theme.NoTitleBar.Fullscreen"
and try setting "android:windowSoftInputMode=adjustResize"
for the activity in AndroidManifest.xml.
You can find details here.
回答4:
If you need this in one activity, you have to put in onCreate, before setContentView:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.your_screen);
回答5:
Add this to your Activity class
@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
}
回答6:
Use this for your 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);
}
回答7:
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);
}
}
You can use this method to hide the status bar. And this is important to hide the action bar too. In this case, you can getSupportActionBar().hide() if you have extended the activity from support lib like Appcompat or you can simply call getActionBar().hide() after the method mentioned above. Thanks
回答8:
Change the theme of application in the manifest.xml
file.
android:theme="@android:style/Theme.Translucent.NoTitleBar"
回答9:
Use this code:
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.youractivityxmlname);
回答10:
Use this code for hiding the status bar in your app and easy to use
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
回答11:
This code hides status bar.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
to hide action bar write this line:-
requestWindowFeature(Window.FEATURE_NO_TITLE);
both lines can be written collectively to hide Action bar and status bar. all these lines must be written before setContentView
method call in onCreate
method.
回答12:
You can hide by using styles.xml
<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>
just call this in your manifest like this android:theme="@style/HiddenTitleTheme"
回答13:
In AndroidManifest.xml -> inside the activity which you want to use, add the following:
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
//this is for hiding action bar
and in MainActivity.java -> inside onCreate() method, add the following :
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
//this is for hiding status bar
回答14:
This is the official documentation about hiding the Status Bar on Android 4.0 and lower and on Android 4.1 and higher
Please, take a look at it:
https://developer.android.com/training/system-ui/status.html
回答15:
You can hide status bar by setting it's color to transperant using xml. Add statusBarColor item to your activity theme:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
回答16:
We cannot prevent the status appearing in full screen mode in (4.4+) kitkat or above devices, so try a hack to block the status bar from expanding.
Solution is pretty big, so here's the link of SO:
StackOverflow : Hide status bar in android 4.4+ or kitkat with Fullscreen
回答17:
This solution work for me :)
@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);
回答18:
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);
}
...
}
回答19:
Used in Manifest
android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen"
回答20:
Under res -> values ->styles.xml
Inside the style body tag paste
<item name="android:windowTranslucentStatus" tools:targetApi="kitkat">true</item>
回答21:
@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);
}
回答22:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
来源:https://stackoverflow.com/questions/5431365/how-to-hide-status-bar-in-android