Линейный макет, перекрывающийся с видом прокрутки и другими линейными макетами - PullRequest
0 голосов
/ 09 февраля 2019

Недавно я столкнулся с проблемой.Мой линейный макет, в котором находится кнопка редактирования текста и изображения, пересекается с моей панелью инструментов и видом прокрутки.Я пробовал другие вещи, такие как 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>

Вот так выглядит предварительный просмотр файла groupchat.xml в Android Studio: введите описание изображения здесь

Так выглядело приложениес этим кодом. Это результаты

На всякий случай, это код моей панели инструментов: 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, потому что я использую его для других видов деятельности в своем приложении, поэтому они включены в Groupchat.xml

ТАКЖЕ Я СОБЛЮДАЮ ЭТУ TUTORILA.Я предлагаю вам пойти и посмотреть его, потому что это то, что я следовал.

перейти к этому видео

Спасибо.

Ответы [ 2 ]

0 голосов
/ 11 февраля 2019

Добавить

 android:layout_below="@+id/group_chat_bar_layout"

эту строку в LinearLayout

<LinearLayout
    android:id="@+id/myLinearLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/group_chat_bar_layout"
    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/bkg" />

</LinearLayout>`
0 голосов
/ 09 февраля 2019

Проблема с размещением макетов.ваш LinearLayout с идентификатором: myLinearLayout нигде не выровнен в RelativeLayout, поэтому он отображается в верхней части экрана.внесите следующие изменения, и вы можете идти.

в вашем LinearLayout с идентификатором myLinearLayout, добавьте эту строку:

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">
...