Mig*_*Slv 7 android android-layout android-statusbar
我的活动使用了CollapsingToolbarLayout,我成功删除了StatusBar这样做:
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
Run Code Online (Sandbox Code Playgroud)
问题是,当softkeyboard弹出时,StatusBar再次出现,消耗宝贵的空间.
如何让它永久隐藏在ActivityView?
如果我将它设置为FullScreen,它可以工作,但我松了SOFT_INPUT_ADJUST_RESIZE参数.主窗口在softkeyboard显示时滚动,而不是根据需要调整大小.
更新:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/my_appar"
android:fitsSystemWindows="false"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="@color/white">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:toolbarId="@+id/collapsetoolbar"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
app:layout_scrollInterpolator="@android:anim/decelerate_interpolator"
app:contentScrim="?attr/colorPrimary">
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:elevation="4dp"
android:layout_height="wrap_content"
android:layout_width="match_parent">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_id"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="... .MyActivity"
android:orientation="vertical"
>
<FrameLayout
android:id="@+id/yt_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<fragment
...
</FrameLayout>
<com.byte_artisan.mchat.compoundViews.chatview.ChatView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/fragment1"
android:id="@+id/chat_view_id">
</com.byte_artisan.mchat.compoundViews.chatview.ChatView>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mchat);
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE );
..
}
@Override
protected void onResume() {
super.onResume();
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
Run Code Online (Sandbox Code Playgroud)
该活动使用NoActionBar方案(在清单上声明).
在您的样式活动样式中添加此行
<item name="android:windowFullscreen">true</item>
Run Code Online (Sandbox Code Playgroud)
除非你用你的活动内容包装ScrollView你不能在全屏活动中使用SOFT_INPUT_ADJUST_RESIZE
为此,您需要将布局内容包装在里面 ScrollView
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- everything you already have -->
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
告诉我它是否有效..
| 归档时间: |
|
| 查看次数: |
2839 次 |
| 最近记录: |