Android 如何制作水平滚动的表格布局?
我有一个带有约束布局的可滚动视图/布局 在这个布局中,我有很多其他的东西。在布局的底部,我需要一个通过编程创建的Tablelayout 如何使此TableLayout可水平滚动Android 如何制作水平滚动的表格布局?,android,kotlin,scroll,scrollview,tablelayout,Android,Kotlin,Scroll,Scrollview,Tablelayout,我有一个带有约束布局的可滚动视图/布局 在这个布局中,我有很多其他的东西。在布局的底部,我需要一个通过编程创建的Tablelayout 如何使此TableLayout可水平滚动 <ScrollView android:id="@+id/testlay" android:layout_width="match_parent" android:layout_height="400dp" androi
<ScrollView
android:id="@+id/testlay"
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_marginTop="5dip"
android:layout_marginStart="60dp"
android:fillViewport="false"
android:scrollbarStyle="outsideInset"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayoutProductTableHeader">
<TableLayout
android:id="@+id/linearLayoutProductTable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:isScrollContainer="true"
android:stretchColumns="*"
tools:ignore="MissingConstraints">
</TableLayout>
</ScrollView>
我也尝试在ScrollView中使用HorizontalLayout,但它不起作用。这就是我如何实现它并为我工作的:
<?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>
好的,我认为问题是因为我通过编程方式添加了表的行和列