【发布时间】:2019-02-09 18:20:58
【问题描述】:
最近遇到一个问题。我的编辑文本和图像按钮所在的线性布局与我的工具栏和滚动视图重叠。我已经尝试过其他的东西,比如 layout_below 等,但没有任何效果。群聊.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>
这是 groupchat.xml 文件在 Android Studio 中的预览效果: enter image description here
这就是应用在这段代码中的样子。 This are the results
以防万一,这是我工具栏的代码:Appbarlayout.xml
<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">
它在一个单独的 xml 中,因为我将它用于我的应用程序中的其他活动,这就是为什么在 th Groupchat.xml 中包含 ang
我也在关注这个 TUTORILA。我建议你去那里看看,因为那是我关注的。
谢谢。
【问题讨论】:
标签: android scrollview android-linearlayout toolbar