首页 > 解决方案 > 以下布局的表格格式未在 android 中显示

问题描述

嗨,在下面的代码中,我正在显示一个表格布局以在表格布局中显示表格行。

用行分隔的每一行要在用户名要显示行之后要显示,然后电子邮件要显示行。任何人都可以帮助我如何添加垂直线来分隔每一行。

请检查以下代码并告诉我

[![在下面的屏幕中描述了我想添加用行分隔的每一行 .like row][1]][1]

[![<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/realmsbg">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_marginTop="20dp"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:gravity="center_horizontal"
            android:background="@drawable/layout_border">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/manage_operator"
                    android:layout_centerHorizontal="true"
                    android:padding="12dp"
                    android:background="@drawable/layout_border"
                    android:textColor="#fff"
                    android:textSize="15sp"
                    android:textStyle="bold"
                    android:gravity="center"
                    android:text="Manage Operator List"/>



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

                    <TableLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">
                        <TableRow
                            android:background="@color/color_gray"
                            android:padding="@dimen/dimen_8dp">
                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:text="Username"
                                android:id="@+id/txtRank"
                                android:textColor="@android:color/white" />
                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:text="Email"
                                android:id="@+id/txtMovieName"
                                android:textColor="@android:color/white" />
                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:text="Mobile"
                                android:id="@+id/txtYear"
                                android:textColor="@android:color/white" />
                        </TableRow>


                    </TableLayout>
                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/my_recycler_view"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="5dp"
                        android:divider="@null"
                        android:nestedScrollingEnabled="false"
                        />
                    <TextView
                        android:id="@+id/empty_view"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:gravity="center"
                        android:text="No Records"
                        android:visibility="gone" />


                </LinearLayout>


        </LinearLayout>

</LinearLayout>][1]][1]

标签: androidlayout

解决方案


您的主要活动布局 XML 文件和您的项目布局 XML 文件。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
            android:id="@+id/llHeader"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/toolbar"
            android:background="@android:color/black"
            android:orientation="horizontal"
            android:paddingTop="@dimen/_8sdp"
            android:paddingBottom="@dimen/_8sdp"
            android:weightSum="3">

        <TextView
                style="@style/textBlackBold"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_weight="1"
                android:gravity="center"
                android:text="Username" />

        <TextView
                style="@style/textBlackBold"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_weight="1"
                android:gravity="center"
                android:text="Email" />

        <TextView
                style="@style/textBlackBold"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_weight="1"
                android:gravity="center"
                android:text="Mobile" />
    </LinearLayout>

    <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerDayAttendance"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@+id/llTotal"
            android:layout_below="@+id/view1" />
</LinearLayout>

推荐阅读