【问题标题】:How can i acheive layout bigger than Screen size viewable on swipe我怎样才能实现大于滑动时可见的屏幕尺寸的布局
【发布时间】:2017-03-06 11:02:55
【问题描述】:

我正在尝试创建一个 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 和 Horizo​​ntalScrollView 在那里,但它们在一个方向上上下或左右工作。 我希望所有方向都顺畅滑动。

我在片段中所做的一切。

【问题讨论】:

  • 使用水平滚动视图
  • 这两种方式都有帮助吗?我的意思是向下、向上、向左滑动所有方式
  • 你可以像这样使用水平滚动视图
  • 为此,您可能需要创建一个嵌套在 Horizo​​ntalScrollView @Shubham Agarwal Bhewanewala 内的 ScrollView
  • 没有其他办法了吗?更好的东西。

标签: android performance android-layout android-view swipe


【解决方案1】:
<?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

【讨论】:

  • 是的,我可以使用它,但它只会帮助我左右。我忘了提到我想在所有可能的方向上一路滑动。
  • 好的,那么我认为这个库会对你有所帮助github.com/InQBarna/TableFixHeaders
  • 感谢您的帮助。
  • 还没有特权。
  • 您将有投票的特权,因为您已经提出了这个问题,并且您可以接受我的回答,我会编辑它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-10
  • 2020-12-08
相关资源
最近更新 更多