2013-05-18 48 views
17

Tôi hoàn toàn bối rối trong cuộn bố cục bảng. Tôi phải triển khai bảng với cuộn ngang và dọc. Tôi cũng đã thấy ví dụ về tiêu đề sửa lỗi bảng nhưng mẫu tablefixheader đã sử dụng bộ điều hợp để đặt dữ liệu nhưng tôi yêu cầu phương thức bổ sung trong bố cục bảng. Tôi đã sử dụng dưới mã nhưng nó không thể hỗ trợ cả hai cách di chuyểnCách cuộn bố cục bảng theo chiều ngang và chiều dọc trong android

 <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:scrollbars="vertical" > 

     <HorizontalScrollView 
      android:layout_width="match_parent" 
      android:layout_height="fill_parent" 
      android:fadeScrollbars="false"> 

      <TableLayout 
       android:id="@+id/tableLayoutId" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 
     </HorizontalScrollView> 
    </ScrollView> 

Trả lời

46

Đây là cách tôi thực hiện nó và làm việc cho tôi:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 
<ScrollView 
    android:id="@+id/layout" 
    android:layout_height="match_parent"   
    android:scrollbars="horizontal|vertical" 
    android:layout_width="match_parent"  
    android:layout_marginTop="5dip"  
    android:scrollbarStyle="outsideInset" 
    android:fillViewport="true"> 

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

     <TableLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:id="@+id/tlGridTable" > 
     </TableLayout> 
    </HorizontalScrollView> 
</ScrollView> 
</LinearLayout> 

Hãy nhìn vào mã này và xem liệu này giúp.

+1

Cảm ơn này và nó hoạt động tuyệt vời ... – user1811379

+1

@ user1811379, bạn chào đón, có một mã hóa tốt đẹp. –

+1

Tuyệt vời +1. Bạn nên thêm một chút giải thích tại sao nó hoạt động =) – user2336315

0

thêm như

<ScrollView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:scrollbars="vertical"> 

     <HorizontalScrollView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <android.support.v7.widget.RecyclerView 
       android:id="@+id/rv_pins" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:scrollbarStyle="outsideOverlay" 
       android:scrollbars="horizontal" /> 
     </HorizontalScrollView> 

    </ScrollView> 
Các vấn đề liên quan