перекрытие экрана в андроид - PullRequest
0 голосов
/ 17 апреля 2019

В приведенном ниже макете у меня есть текстовое представление, названное устройством сканирования. В нем отображается имя устройства, но мой список устройств отображался над экраном.

Может кто-нибудь, пожалуйста, помогите мне, как прокрутить представлениедолжен находиться внутри списка устройств. При прокрутке экрана отображался список устройств, но он отображался над экраном.

хотите отобразить внутри экрана.

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:orientation="vertical">

    <android.support.design.widget.AppBarLayout
        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="wrap_content">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/back"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:padding="10dp"
                    android:text="@string/back"
                    android:textAllCaps="true"
                    android:textColor="@color/white"
                    android:visibility="invisible" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:padding="10dp"
                    android:textStyle="bold"
                    android:text="@string/lamp_list"
                    android:textAllCaps="true"
                    android:textColor="@color/white" />

                <TextView
                    android:id="@+id/refresh"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:drawableRight="@drawable/refresh"
                    android:gravity="right"
                    android:padding="10dp"
                    android:textAllCaps="true"
                    android:textColor="@color/white" />

                <ProgressBar
                    android:id="@+id/scanningProgress"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:visibility="gone" />
            </LinearLayout>
        </android.support.v7.widget.Toolbar>
    </android.support.design.widget.AppBarLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="?attr/actionBarSize"
        android:background="@drawable/baground"
        android:orientation="vertical">

        <TextView
            android:id="@+id/scan_status"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="18dp"
            android:gravity="center"
            android:text="@string/start_discovery"
            android:textColor="@color/white"
            android:visibility="gone"
            tools:visibility="visible" />


        <android.support.v7.widget.RecyclerView
            android:id="@+id/deviceListView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </LinearLayout>

</android.support.design.widget.CoordinatorLayout>

Inприведенный ниже макет подключения textview выходил из макета.

device_item.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="horizontal"
    android:padding="10dp">


    <ImageView
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:padding="6dp"
        android:src="@drawable/lamp" />

    <TextView
        android:id="@+id/deviceName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="left"
        android:textColor="@color/white"
        android:textSize="17sp"
        tools:text="Solar Enviro SSL 2016" />

    <TextView
        android:id="@+id/connect"
        android:layout_width="wrap_content"
        android:layout_height="22dp"
        android:background="@drawable/rounded_red_view"
        android:text="@string/connect"
        android:paddingBottom="1dp"
        android:paddingTop=".2dp"
        android:paddingLeft="15dp"
        android:paddingRight="15dp"
        android:textColor="@color/white"
        android:textSize="17sp" />
</LinearLayout>

Ответы [ 2 ]

0 голосов
/ 18 апреля 2019

Вместо CoordinatorLayout используйте линейную разметку.

, если начинающий пользователь начинает кодирование с линейной разметкой.Это легко понять.

<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
0 голосов
/ 17 апреля 2019

изменить это вещи .. использовал оба wrap_content. Я надеюсь, что вы также удалите панель действий по умолчанию.

 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="?attr/actionBarSize"
        android:orientation="vertical">

    <TextView
            android:id="@+id/scan_status"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="18dp"
            android:gravity="center"
            android:visibility="gone"
            tools:visibility="visible" />


    <android.support.v7.widget.RecyclerView
            android:id="@+id/deviceListView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

</LinearLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...