2014-09-25 158 views
-1

我在table layout中动态添加tablerows。当我使用垂直和水平滚动条时。由于水平滚动,我在布局中获得了一些空间。我的XML文件是─删除水平滚动条的空间

<?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/scrollView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:scrollbars="none"> 

     <HorizontalScrollView 
     android:id="@+id/horizontalScrollView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:scrollbars="none"> 

<TableLayout 
     android:stretchColumns="*" 
     android:id="@+id/main_table" 
     android:layout_weight="1" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent"> 


</TableLayout> 
     </HorizontalScrollView> 
    </ScrollView> 







</LinearLayout> 

截图是 -

enter image description here

我想删除从右边那个空间。

+0

你试过'机器人:layout_weight = “WRAP_CONTENT”'你'TableLayout' – 2014-09-25 06:35:28

+0

Anushka,我认为你必须设置layout_width =” match_parent“ – 2014-09-25 06:36:32

+0

plz发布您的布局行xml文件 – 2014-09-25 06:39:07

回答

2

简单的变化

<ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:scrollbars="none"> 

    <HorizontalScrollView 
    android:id="@+id/horizontalScrollView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:scrollbars="none"> 

这个

<ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:scrollbars="none"> 

    <HorizontalScrollView 
    android:id="@+id/horizontalScrollView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:scrollbars="none"> 
+0

(所以将wrap_content更改为match_parent的宽度) – 2014-09-25 06:46:31

+0

@Kostya Khuta-它不工作。继续将它放在右侧。 – 2014-09-25 06:48:58

+0

它是你的整个XML文件? – 2014-09-25 06:51:50