我现在有一个消息发送和接收布局和工具栏现在我专注于edittext for wrting消息整个布局向上移动但工具栏也向上移动我使用adjustPan和adjustResize,fitwindows true isScrollSontainer true。总之尝试所有解决方案,但都是徒劳的。 我在片段中打开了这个消息视图布局作为子
//main
<?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_main"
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>
appbarmain:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.app.collbatt.ui.NavigationActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"
app:layout_scrollFlags="enterAlways">
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="@android:color/white"
android:textSize="@dimen/text_size_medium" />
<ImageView
android:id="@+id/img_createRecord"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:src="@drawable/icon_createrec_white" />
<ImageView
android:id="@+id/img_avatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:src="@drawable/app_logo" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<include
android:id="@+id/content_main"
layout="@layout/content_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/appbar" />
</RelativeLayout>
//contentMain:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.app.collbatt.ui.NavigationActivity">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:isScrollContainer="true"
android:layout_height="match_parent" />
</RelativeLayout>
//MessageView:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/view_main"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/app_bg">
<com.github.rahatarmanahmed.cpv.CircularProgressView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/progress_view"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:cpv_animAutostart="true"
app:cpv_indeterminate="true" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_Messages"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_above="@+id/layout_messagebox"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="8dp" />
<!-- A horizontal line between the chatbox and RecyclerView -->
<View
android:layout_width="0dp"
android:layout_height="2dp"
android:layout_above="@+id/layout_messagebox"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="0dp"
android:background="#dfdfdf" />
<LinearLayout
android:id="@+id/layout_messagebox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="#ffffff"
android:minHeight="48dp"
android:orientation="horizontal">
<EditText
android:id="@+id/et_messagebox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_weight="1"
android:background="@android:color/transparent"
android:hint="Type Message..."
android:imeOptions="actionSend"
android:maxLines="6" />
<Button
android:id="@+id/btn_send"
android:layout_width="56dp"
android:layout_height="56dp"
android:background="@drawable/icon_send" />
</LinearLayout>
</RelativeLayout>
//Manifest:
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="APP"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
tools:replace="icon,label">
<!--Navigation Activity-->
<activity
android:name=".ui.NavigationActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme_Nav"></activity>
</application>
答案 0 :(得分:1)
<activity
android:windowSoftInputMode="stateVisible|adjustResize" ... >
...
</activity>
答案 1 :(得分:0)
在您的AndroidManifest.xml中添加以下代码,在您的Activity
中android:windowSoftInputMode="adjustResize"