2017-03-06 184 views
0

我想创建一个可能比屏幕宽度大一些的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> 

这里发生了什么事究竟是在视图中多余的部分获取隐藏搞清楚。 但是我想要的是看到隐藏的视图,并且在整个视图中对该视图具有类似的控制权,当我以目前不可能的方向轻扫时。是否有可能实现?如果是,我怎么能通过它?

重要 滚动型和Horizo​​ntalScrollView是有,但他们在一个方向上工作,要么上下或左右。 我想所有的方向滑动顺利。

我正在做一个片段。

+1

使用horizo​​ntalscrollview – Nilabja

+0

是否有助于左右逢源我的意思向下滑动,向上,左,右各方面 –

+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

+0

是的,我可以使用它,但它只会帮助我左和右。我忘了提及我想以各种方式轻扫。 –

+0

好吧然后我认为这个库会对你有所帮助https://github.com/InQBarna/TableFixHeaders –

+0

谢谢你的帮助。 –