android tablelayout在使用horizontalscrollview时被破坏

pzfprimi  于 2021-07-12  发布在  Java
关注(0)|答案(0)|浏览(217)

我想创建一个如下所示的布局,它是半隐藏的,必须水平滚动才能看到所有内容,但我的布局有问题,因此有人可以帮助我解决这种情况下的暗解决方案:
我的设计:

这里我使用linearlayout作为tablelayout的标题,然后使用tablerow作为表行。
使用tablelayout和tablerow的我的xml布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="@dimen/padding_16dp">

    <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="none">

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

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

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="12sp"
                    android:text="STT" />

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="4"
                    android:orientation="vertical">

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

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Samsung device maket"
                            android:textColor="#000000"
                            android:textSize="12sp" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="10dp"
                            android:layout_marginLeft="10dp"
                            android:text="Apple device market"
                            android:textColor="#000000"
                            android:textSize="12sp" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Smartphone"
                            android:textColor="#000000"
                            android:textSize="12sp" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="10dp"
                            android:layout_marginLeft="10dp"
                            android:text="Laptop"
                            android:textColor="#000000"
                            android:textSize="12sp" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="10dp"
                            android:layout_marginLeft="10dp"
                            android:text="Smartphone"
                            android:textColor="#000000"
                            android:textSize="12sp" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="10dp"
                            android:layout_marginLeft="10dp"
                            android:text="Laptop"
                            android:textColor="#000000"
                            android:textSize="12sp" />
                    </LinearLayout>
                </LinearLayout>
            </LinearLayout>

            <View
                android:layout_width="match_parent"
                android:layout_height="0.75dp"
                android:layout_marginVertical="@dimen/margin_15dp"
                android:background="@color/dove_gray" />

            <TableLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TableRow android:paddingVertical="10dp">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="sbshas"
                        android:textColor="#000000"
                        android:textSize="12sp" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Abcd"
                        android:textSize="12sp" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginHorizontal="10dp"
                        android:text="sbshas"
                        android:textSize="12sp" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="sbshas"
                        android:textSize="12sp" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginHorizontal="10dp"
                        android:text="sbshas"
                        android:textSize="12sp" />
                </TableRow>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="0.75dp"
                    android:background="#707070" />

            </TableLayout>
        </LinearLayout>
    </HorizontalScrollView>

</LinearLayout>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题