最近我encounterd问题。我的线性布局,其中我的编辑文本和图像按钮是在与我的工具栏和我的滚动视图重叠。我尝试过其他的东西像layout_below等并没有什么工作。 Groupchat.xml
<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"
tools:context=".GroupChatActivity"
android:orientation="vertical">
<include
android:id="@+id/group_chat_bar_layout"
layout="@layout/app_bar_layout">
</include>
<ScrollView
android:id="@+id/my_scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/group_chat_bar_layout"
android:layout_above="@+id/myLinearLayout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/group_chat_text_display"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:textAllCaps="false"
android:textSize="20sp"
android:textColor="@android:color/background_dark"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginBottom="50dp"/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/myLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/input_group_message"
android:layout_width="270dp"
android:layout_height="wrap_content"
android:hint="Write message..." />
<ImageButton
android:id="@+id/send_message_button"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:src="@drawable/send_message" />
</LinearLayout>
这是该集团chat.xml文件的预览外观Android Studio中:qazxsw POI
这是应用程序如何看待这个代码。 enter image description here
以防万一,这是我的工具栏的代码:Appbarlayout.xml
This are the results
它在一个单独的XML,因为我用它在我的应用程序多数民众赞成等活动,为什么那里有陈子昂包括本集团Chat.xml
ALSO我下面这个教程。我建议你去那里,看看它,因为那是我紧随其后。
<android.support.v7.widget.Toolbar
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/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
谢谢。
问题是与布局的展示位置。 ID为您的LinearLayout:myLinearLayout没有在任何地方RelativeLayout的排列,这就是为什么它是越来越在屏幕上方呈现。做出以下更改和你的好去。
与ID您的LinearLayout:myLinearLayout,加入这一行:
go to this video
像这样:
android:layout_alignParentBottom="true"
加
<LinearLayout
android:id="@+id/myLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
这条线的LinearLayout
android:layout_below="@+id/group_chat_bar_layout"