How to make a scrollable TableLayout?

后端 未结 4 1653
后悔当初
后悔当初 2021-02-01 00:23

Look at the XML code here please:



        
相关标签:
4条回答
  • 2021-02-01 01:01

    You don't technically need the LinearLayout in the ScrollView:

    <ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scrollbars="none"
    android:layout_weight="1">
    
        <TableLayout
        android:id="@+id/tableLayout1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="10dip"
        android:isScrollContainer="true">
    
        <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    
            <--!Everything Else You Already Have-->
    
        </TableRow>
     </TableLayout>
    </ScrollView>
    

    Once you take up enough room within the ScrollView, the scrolling effect will activate (kind of like an HTML TextArea, once you have enough lines of text, the scrolling activates.)

    You can also nest the ScrollView, but again you cannot feel the scrolling effect until you have enough content in the ScrollView.

    0 讨论(0)
  • 2021-02-01 01:02

    Encase the whole thing in:

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scrollbars="none"
        android:layout_weight="1">
        <LinearLayout
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical">
    
        ...
    
    </ScrollView>
    
    0 讨论(0)
  • 2021-02-01 01:04

    It works too inside Constraint Layout. Just add the following attributes on your TabLayout.

    <android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
            <TableLayout
                android:id="@+id/tableLayout"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:isScrollContainer="true">
    
            . . .
    
    0 讨论(0)
  • 2021-02-01 01:07

    thanks mbauer it's solved my problem i place in order

    1. TableLayout
    2. TableRow with end (for the header of columns)
    3. ScrollView
    4. LinearLayout
    5. x TableRow with end
    6. end LinearLayout
    7. end ScrollView
    8. end TableLayout
    0 讨论(0)
提交回复
热议问题