简体   繁体   English

表格布局可以同时具有水平和垂直滚动视图吗

[英]Can Table Layout have both horizontal and vertical scroll view

Hi i created a Table Layout with normal Scroll view, I want it to scroll both vertical and horizontal. 嗨,我创建了一个具有正常滚动视图的表布局,我希望它同时滚动垂直和水平方向。 In XML is it possible or if there is any other solution to solve as my text is going out of table once it exceeds the length and it makes the table layout bigger and moves oout of the device. 在XML中是可能的,或者有其他解决方案可以解决,因为我的文本一旦超出长度,就会超出表的范围,这会使表布局变大并移出设备。

<ScrollView android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/linearImag">

    <LinearLayout
        android:id="@+id/relativelayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

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

        </LinearLayout>

        <TableLayout
            android:id="@+id/lead_table"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="20dp"
            android:gravity="center"
            android:stretchColumns="*" >

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

                <Button
                    android:id="@+id/textView2"
                    android:layout_width="wrap_content"
                    android:layout_height="25dp"
                    android:background="@drawable/bgbtn"
                    android:text="Lead ID"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:textSize="20sp" />
        </TableLayout>

        <Button
            android:id="@+id/btn_add"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_marginLeft="25dp"
            android:layout_marginTop="20dp"
            android:background="@drawable/add" />

        <TextView
            android:id="@+id/tv_data"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </LinearLayout>
    </ScrollView>

Instead of normal scroll view , use horizontal scroll view like 代替普通滚动视图,使用水平滚动视图,例如

<Layout>
 <HorizontalScrollView 
        android:id="@+id/horizontalView" 
        android:layout_height="wrap_content"     
        android:scrollbars="horizontal|vertical" 
        android:layout_width="wrap_content"     
        android:layout_marginTop="5dip">
<TableLayout>
    // child views...
</TableLayout>
</HorizontalScrollView>
</Layout>

Hope this will solve your problem :-) 希望这能解决您的问题:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM