2017-03-06 103 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

謝謝你的幫助。 –