Android的:无法正确设置TableLayout通缉 [英] Android : Unable to set TableLayout properly as wanted

查看:187
本文介绍了Android的:无法正确设置TableLayout通缉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我显示在活动从DB数据。我想在底部的表和按钮。对于数据认为TableLayout将是其最好的选择。我加了TableLayout到Horizo​​ntalView&安培;以滚动型使其与垂直滚动放大器;水平。我将所有行动态 - 包括头。这部分工作正常。

I am showing data from DB in an Activity. I want a Table and buttons on bottom. For data thought TableLayout would be best option for it. I added TableLayout to HorizontalView & to ScrollView making it scroll vertically & Horizontally. Am adding all rows dynamically - including header. This part is working fine.

我要的是当内容小于屏幕的宽度,它应该还没有占据整个屏幕宽度。对于如。如果一个表在人像模式风景模式非常适合然后ofcourse他们将留在右边空白处。我不希望这样的空间EB空的,而不是由所有列占据。如果行宽度比屏幕的宽度更大的则没有问题在所有 - 。如显示horiontal滚动

I want is when the contents is less than the screen width, it should yet occupy the whole screen width. For eg. If a table fits well in Portrait mode then ofcourse for Landscape mode their will be blank space left on the right. I don't want that space to eb empty, instead to occupy by all columns. If the row width is greater than the screen width then no issues at all - as horiontal scrollbar appears.

我试过了一些变化,但没有任何帮助的。任何想法,以什么设置utlize的所有空间(如果有的话AVBL)及展示下。

I tried few variations, but nothing helped out. Any idea what settings to make to utlize all space (if at all avbl) & show it.

是的,另外1个水平滚动条的问题,这似乎只是在最后一排。我希望它
最后出现一行如下 - 让最后一排的边界是可见的。我的XML:

And yes, 1 more issue of horizontal scrollbar, it appears just on the last row. I want it to appear below last row - so the border of last row is visible. My XML :

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
 android:layout_height="fill_parent" android:orientation="vertical">

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:scrollbars="horizontal|vertical">

<HorizontalScrollView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginBottom="10dp" > 

<TableLayout android:id="@+id/browseTable" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_marginBottom="20dp"
    android:background="#FF0000" android:stretchColumns="1,2,3">

</TableLayout>

</HorizontalScrollView>
</ScrollView>

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content" 
android:orientation="horizontal"  android:gravity="center" 
android:layout_marginTop="15dp">
    <Button android:id="@+id/browseAddBtn" android:text="Add" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:layout_marginRight="10dp" />
    <Button android:id="@+id/browseViewBtn" android:text="Edit" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:layout_marginRight="10dp"  />
    <Button android:id="@+id/browseReturnBtn" android:text="Return" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" />        
  </LinearLayout>

</LinearLayout>

输出:

OUTPUT :

推荐答案

我发现一件事情,而解决您的问题,关于 TableLayout Horizo​​ntalScrollView 使用时。在的android:stretchColumns 是不是当我们使用表布局内的水平滚动视图中工作。所以你得到空白屏幕时,旋转或列具有更少的宽度数据。

I found one thing while solving your problem, about TableLayout when used inside a HorizontalScrollView. The android:stretchColumns is not working when we use Table Layout inside Horizontal Scroll View. So that you are getting blank space when screen is rotated or columns have less width data.

我希望你明白这一点。我试图用一些其他的替代水平滚动视图来解决这个问题。我将发布的答案,如果我得到的解决方案。再见。

I hope you understand this. I am trying to solve this problem by replacing Horizontal Scroll View with some other. I will post answer if i get solution. Bye.

修改

TVD 最后我得到了你的问题的解决方案。更改您的XML布局文件下面。

Hi Tvd finally I got the solution for your problem. make below changes to your XML layout file.

&LT; Horizo​​ntalScrollView&GT;

使用

        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:fillViewport="true"

使用 stretchColumns =* TableLayout 如果你想被拉伸的所有列。

Use stretchColumns = "*" in TableLayout if you want all columns to be stretched.

再见。 : - )

这篇关于Android的:无法正确设置TableLayout通缉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆