我正在尝试创建一个xml布局,它可能比屏幕的宽度大一些甚至高度。因为我将在xml中添加表格,所以可能存在布局宽度和高度超过屏幕宽度和高度的情况。我试着找出以下代码 -
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent"
tools:context="com.example.shaby.payshare.WorkPageOneFragment">
<TableLayout
android:layout_width="800dp"
android:layout_height="400dp">
</TableLayout>
</RelativeLayout>
这里发生的事情是视图中的额外部分被隐藏了。 但我想要的是看到隐藏的视图,并且当我向那个目前不可能的方向滑动时,在整个视图中具有类似的控制权。有可能实现吗?如果是,我怎么能通过它?
重要 ScrollView和HorizontalScrollView在那里,但它们可以向上或向下或向左和向右一个方向工作。 我希望所有方向都能顺利滑动。
我在片段中所做的一切。
答案 0 :(得分:0)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<HorizontalScrollView
android:id="@+id/horizontalScrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TableLayout
android:id="@+id/bot_scoreBoard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/table_shape"
android:orientation="horizontal"
android:stretchColumns="*" >
<TableRow
android:layout_height="fill_parent"
android:layout_margin="2dp"
android:background="#ffffff" >
<TextView />
more than 16 columns of made using TextView
....
</TableRow>
</TableLayout>
</LinearLayout>
如果您想向所有方向滑动,那么此库对您https://github.com/InQBarna/TableFixHeaders
非常有帮助