0

我当前的布局是

在此处输入图像描述

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

<ScrollView
    android:id="@+id/scrMain"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:layout_gravity="top"
    android:fillViewport="true" >


    <RelativeLayout
        android:id="@+id/rl"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <RelativeLayout
            android:id="@+id/llGridToday"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" android:visibility="gone">

            <FrameLayout
                android:id="@+id/FrameLayout1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true" >

                <ImageView
                    android:id="@+id/imageView2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/gridframe" />

                <FrameLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="right"
                    android:layout_marginRight="10dp"
                    android:layout_marginTop="10dp"
                    android:background="@drawable/calender" >

                    <TextView
                        android:id="@+id/txtDateToday"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:gravity="center"
                        android:text="28" />
                </FrameLayout>

                <TextView
                    android:id="@+id/textView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_marginTop="3dp"
                    android:text="Today"
                    android:textColor="#000" />
            </FrameLayout>

            <GridView
                android:id="@+id/gridToday"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:layout_below="@+id/FrameLayout1"
                android:layout_weight="1"
                android:numColumns="3" >
            </GridView>
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/llGridTomorrow"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/llGridToday"
            android:orientation="vertical" android:visibility="gone">

            <FrameLayout
                android:id="@+id/FrameLayout1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true" >

                <ImageView
                    android:id="@+id/ImageView01"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/gridframe" />

                <FrameLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="right"
                    android:layout_marginRight="10dp"
                    android:layout_marginTop="10dp"
                    android:background="@drawable/calender" >

                    <TextView
                        android:id="@+id/txtDateTomorrow"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:gravity="center"
                        android:text="28" />
                </FrameLayout>

                <TextView
                    android:id="@+id/TextView02"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_marginTop="3dp"
                    android:text="Tomorrow"
                    android:textColor="#000" />
            </FrameLayout>

            <GridView
                android:id="@+id/gridTomorrow"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:layout_below="@+id/FrameLayout1"
                android:layout_weight="1"
                android:numColumns="3" >
            </GridView>
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/llGridMonth"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/llGridTomorrow"
            android:orientation="vertical" android:visibility="gone">

            <FrameLayout
                android:id="@+id/FrameLayout1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true" >

                <ImageView
                    android:id="@+id/ImageView02"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/gridframe" />

                <TextView
                    android:id="@+id/TextView03"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="5dp"
                    android:layout_marginTop="2dp"
                    android:text="This Month"
                    android:textColor="#000" />
            </FrameLayout>

            <GridView
                android:id="@+id/gridMonth"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_below="@+id/FrameLayout1"
                android:numColumns="3" android:stretchMode="columnWidth">
            </GridView>
        </RelativeLayout>
    </RelativeLayout>
</ScrollView>

Layout包含三个GridViews. 我正在用逻辑使 Parent可见RelativeLayoutGridViews并将膨胀的ImageView+添加TextViewGridView.

它看起来不错。但没有滚动。

4

2 回答 2

2

是的,拥有三个不同的点有什么意义GridView。只需创建一个GridView作为父级并具有单独的布局,GridItem以便您可以按照需要的方式对其进行样式设置。

更新

这样的东西不适合你吗???

具有以下代码的一种布局

        <GridView 
            android:id="@+id/gridTomorrow" 
            android:layout_width="match_parent" 
            android:layout_height="wrap_content" 
            android:layout_alignParentBottom="true" 
            android:layout_alignParentLeft="true" 
            android:layout_below="@+id/FrameLayout1" 
            android:layout_weight="1" 
            android:numColumns="3" > 
        </GridView>

和另一个布局GridItem

        <FrameLayout   
            android:id="@+id/FrameLayout1"   
            android:layout_width="match_parent"   
            android:layout_height="wrap_content"   
            android:layout_alignParentLeft="true"   
            android:layout_alignParentTop="true" >   

            <ImageView   
                android:id="@+id/ImageView01"   
                android:layout_width="wrap_content"   
                android:layout_height="wrap_content"   
                android:src="@drawable/gridframe" />   

            <FrameLayout   
                android:layout_width="wrap_content"   
                android:layout_height="wrap_content"   
                android:layout_gravity="right"   
                android:layout_marginRight="10dp"   
                android:layout_marginTop="10dp"   
                android:background="@drawable/calender" >   

                <TextView   
                    android:id="@+id/txtDateTomorrow"   
                    android:layout_width="wrap_content"   
                    android:layout_height="wrap_content"   
                    android:layout_gravity="center"   
                    android:gravity="center"   
                    android:text="28" />   
            </FrameLayout>   

            <TextView   
                android:id="@+id/TextView02"   
                android:layout_width="wrap_content"   
                android:layout_height="wrap_content"   
                android:layout_marginLeft="10dp"   
                android:layout_marginTop="3dp"   
                android:text="Tomorrow"   
                android:textColor="#000" />   
        </FrameLayout> 

使用GridAdapter Inflate你的GridItems进入网格

于 2012-03-29T19:53:00.457 回答
0

不知道为什么你需要三个不同的GridView.

尝试制作GridView父项并将其余View项目添加为GridView标题。

于 2012-03-29T19:50:26.163 回答