Android 带有表格布局和线性布局的滚动视图

Android 带有表格布局和线性布局的滚动视图,android,android-layout,android-linearlayout,android-scrollview,android-relativelayout,Android,Android Layout,Android Linearlayout,Android Scrollview,Android Relativelayout,我有一个滚动视图布局和一个表格布局,其中我有一个表格行,它由三个文本视图组成 当我尝试将文本视图与屏幕对齐时,问题就出现了。TextViews不会占用屏幕空间,而且有点拥挤 我也附上了代码,如果你们需要检查它 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http:

我有一个
滚动视图
布局和一个
表格布局
,其中我有一个
表格行
,它由三个
文本视图
组成

当我尝试将
文本视图
与屏幕对齐时,问题就出现了。
TextViews
不会占用屏幕空间,而且有点拥挤

我也附上了代码,如果你们需要检查它

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_reciept"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.spuck.LayoutTable">

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/relativeLayout">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="49dp"
            android:src="@drawable/the_one_3"
            android:id="@+id/the_one"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true" />


    </RelativeLayout>
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:id="@+id/scrollView2"
        android:layout_below="@+id/relativeLayout"
        android:layout_above="@+id/addButton">


            <TableLayout
                android:id="@+id/maintable"
                android:layout_width="match_parent"
                android:layout_height="300dp">

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:id="@+id/tableRow1">

                    <LinearLayout android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:id="@+id/linear_layout_two_table_layout">


                        <TextView
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:text="Date"
                            android:textAlignment="center"
                            android:textSize="20dp"
                            android:layout_weight="0.5"
                            android:background="@drawable/cell_shape"
                            />

                        <TextView
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:text="Session Time"
                            android:textSize="20dp"
                            android:layout_weight="1"
                            android:background="@drawable/cell_shape"
                            />

                        <TextView
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:text="Average Speed"
                            android:layout_gravity="center"
                            android:textSize="20dp"
                            android:layout_weight="1"
                            android:background="@drawable/cell_shape"
                            />

                    </LinearLayout>
                </TableRow>
            </TableLayout>

    </ScrollView>


    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/addButton"
        android:text="Scan item barcode"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

</RelativeLayout>

在LinearLayout
android:layout\u weight=“2.5”
中设置,它是LinearLayout子级的布局权重之和。在此之后,布局应左右对齐

<LinearLayout android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_weight="2.5"
    android:id="@+id/linear_layout_two_table_layout">


我肯定会试试这个,现在我已经进入另一个问题,我在最后的同一个布局中添加了导航菜单和底部导航栏,现在它不会显示表格。知道吗?抱歉,没有源代码,很难说问题出在哪里。我试着在本教程的基础上实现底部导航栏,结果是:没有添加导航菜单,但它不应该破坏表格。如果你仍然有问题,我想你应该发布一个新问题。让我们聊聊吧,我是StackOverflow的新手,所以如果你也不能写太多关于StackOverflow的文章,请先发消息给我,并且创建聊天室需要100的声誉。所以现在我错过了4个开始聊天的机会。好吧,如果可能的话,我们还有其他的方式可以讨论这个问题吗。。。。