【发布时间】:2018-01-23 09:39:15
【问题描述】:
我现在在顶部有一个消息发送和接收布局和工具栏,当我专注于编辑文本以编写消息时,整个布局向上移动,但工具栏也向上移动我使用了 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>
【问题讨论】:
-
你能分享你的 AndroidMenifest.XML 文件吗?
-
@AkashPal 查看更新的问题
-
@AkashPal 我应该使用它吗?基本上它包含在我从不同解决方案中获得的尝试中。如果我使用它或不使用它,同样的事情会发生
-
@AkashPal 不工作
-
@YokaiTheMonster 也与 stackoverflow.com/questions/45631432/… 有关。但问题是这些解决方案根本不起作用。
标签: android