在android中重叠屏幕 [英] overlapping a screen in android

查看:53
本文介绍了在android中重叠屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的布局中,我有一个名为扫描设备的文本视图.其中显示的是设备名称,但我的设备列表显示在屏幕上方.

In the below layout i have a text view named as scanning device.In that am displaying a device name But my device list was displaying above the screen .

任何人都可以帮助我如何滚动视图应该在设备列表内.滚动屏幕时它正在显示设备列表但它显示在屏幕上方.

can any one please help me how to scroll view should be inside the device list.while scrolling the screen it was displaying the list of the devices but it is displaying above the screen.

想要在屏幕内显示.

<?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>

在下面的布局中,连接 textview 是从布局中出来的.

In the below layout connect textview was coming out of the layout.

device_item.xml:

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>

推荐答案

使用线性布局代替 CoordinatorLayout.

Instead of CoordinatorLayout use linear layout.

如果你是初学者,开始使用线性布局编码.很容易理解.

if u r a beginner start coding with linear layout. It is easy to understand.

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

这篇关于在android中重叠屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆