如何添加多个孩子在android的水平滚动视图 [英] how to add multiple child in horizontal scroll view in android

查看:129
本文介绍了如何添加多个孩子在android的水平滚动视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此应用程序,我使用JSON解析和使用名单适配器绑定数据标签中的数据,我是添加标题为静态使用表布局的数据,当我和水平滚动数据滚动标题,但水平滚动视图只允许只有一个孩子,我需要一个水平滚动视图中的两个布局。请大家帮忙

In this application i tag the data using json parsing and binding the data using list adapter and i was add the heading for data in static using table layout, when i scroll horizontally the data scroll with heading but horizontal scroll view only allowed to only one child, i need two layout in single horizontal scroll view. please help

我的XML是

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:background="#ffffff"
     android:orientation="vertical">
<!-- Main ListView Always give id value as list(@android:id/list) -->
   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:background="#ffffff"
         android:orientation="horizontal">

     <TableRow
         android:id="@+id/tableRow1"
         android:scrollbarAlwaysDrawHorizontalTrack="true"
         android:layout_height="wrap_content"
         android:layout_width="match_parent">

         <TextView
            android:id="@+id/TextView2"
            android:text="GRPName"
            android:background="#A513FF"

            android:textColor="#000000"
            android:layout_width="150dp"
            android:padding="3dip"
            android:gravity="left"/>

         <TextView
            android:id="@+id/TextView3" android:text="NAME"
            android:background="#A513FF"
            android:textColor="#000000"
            android:layout_width="100dp"
            android:padding="3dip" android:gravity="left"/>

         <TextView
            android:id="@+id/TextView4" android:text="MRP"
            android:background="#A513FF"
            android:textColor="#000000"
            android:layout_width="100dp"
            android:padding="3dip" android:gravity="left"/>

         <TextView
            android:id="@+id/TextView5" android:text="QNT"
            android:background="#A513FF"
            android:textColor="#000000"
            android:layout_width="100dp"
            android:padding="3dip" android:gravity="left"/>

         <TextView
            android:id="@+id/TextView2" android:text="ID"
            android:background="#A513FF"
            android:textColor="#000000"
            android:layout_width="100dp"
            android:padding="3dip"
            android:gravity="left"/>

        <TextView
            android:id="@+id/TextView3" android:text="NAME"
            android:background="#A513FF"
            android:textColor="#000000"
            android:layout_width="100dp"
            android:padding="3dip" android:gravity="left"/>

    </TableRow>
  </LinearLayout>

  <HorizontalScrollView
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:id="@+id/horizontalScrollView">
    <ListView
            android:id="@android:id/list"
            android:smoothScrollbar="true"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
  </HorizontalScrollView>
</LinearLayout>

我要表布局在水平滚动视图

I need to table layout in the horizontal scroll view

推荐答案

您必须把一个布局作为scrollviews孩子,然后把所有其他意见,这个孩子,它应该工作正常。

You have to put one layout as a scrollviews child, then put every other views in that child and it should work fine.

像这样的:

<HorizontalScrollView
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:id="@+id/horizontalScrollView">

    <LinearLayout ... >
    ... insert your views in here
    </LinearLayout>
</HorizontalScrollView>

这篇关于如何添加多个孩子在android的水平滚动视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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