Tôi gặp sự cố khi tải GridLayout để cuộn theo chiều ngang.Cuộn ngang, ngang và dọc cho GridLayout
Tôi đã tìm thấy câu hỏi tương tự Gridlayout + ScrollView. Tôi đã thử phương pháp đó, nhưng nó không hoạt động.
Nó cắt ra nhiều bảng (vì nó được cho là sẽ hiển thị tất cả các bảng từ 1 đến 20).
Dưới đây là file xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="16dp" >
<android.support.v7.widget.GridLayout
android:id="@+id/table_mapGrid"
android:layout_width="250dp"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
<include layout="@layout/cell_list_loading" />
<TextView
android:id="@+id/table_errorView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="20dp"
android:text="@string/message_error_connection"
android:visibility="invisible" />
</FrameLayout>
Tôi muốn có nội dung động hiển thị, thay đổi số lượng các cột và các hàng có thể với khoảng trống giữa các bảng. Điều này tôi đã hoàn thành, nhưng vấn đề là khi chiều rộng của GridLayout trở nên lớn hơn vùng chứa của nó, tôi muốn giải quyết bằng cách sử dụng cuộn ngang, nhưng dường như không hoạt động ...
Bất kỳ đề xuất nào?
là có anyways để làm điều đó programeticaly trong android? –
Có, bạn chỉ cần tạo cùng một nội dung từ bên trên, nhưng theo lập trình. mScrollView.addView (mHorizontalScrollView); mHorizontalScrollView.addView (yourContentHere); –