当Gone布局设置为可见时,使用GridView和按钮挤压可见RelativeLayout

时间:2012-12-04 09:12:31

标签: android android-layout relativelayout

我有一个RelativeLayout1大约是屏幕宽度的一半,最初设置为GONE ..另一个布局RelativeLayout2,它必须获取screenWidth设置为左边..根据我设置RelativeLayout1 VISIBLE它应该设置RelativeLayout2到向左移位而不是将RelativeALyout2挤压到左边的屏幕宽度。

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

    <RelativeLayout
        android:id="@+id/menulayout"
        android:layout_width="200dp"
        android:layout_height="fill_parent"
        android:layout_alignParentRight="true" >

        <RelativeLayout
            android:id="@+id/topMenubar"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:background="@drawable/slider_header"
            android:fitsSystemWindows="true" >

            <TextView
                android:id="@+id/menu"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="5dp"
                android:text="@string/menu"
                android:textColor="#787878" >
            </TextView>
        </RelativeLayout>

        <ListView
            android:id="@+id/menulist"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_below="@id/topMenubar"
            android:background="#232323"
            android:cacheColorHint="#00000000"
            android:divider="#5b5b5b"
            android:dividerHeight="1dp"
            android:scrollbars="none" />

        <Button
            android:id="@+id/backmenu"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:background="@drawable/arrowleft" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/maingridlayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_toLeftOf="@id/menulayout" >

        <RelativeLayout
            android:id="@+id/topBar"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:background="@drawable/header_bg"
            android:fitsSystemWindows="true" >

            <ImageView
                android:id="@+id/handle"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:src="@drawable/handle" />

            <TextView
                android:id="@+id/notificationnumber"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:background="@drawable/redbatch"
                android:gravity="center"
                android:textColor="#ffffff"
                android:textSize="20dp"
                android:visibility="gone" />

            <ImageView
                android:id="@+id/searchnow"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:src="@drawable/searchunsel" />

            <RelativeLayout
                android:id="@+id/logolayout"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:layout_toLeftOf="@id/handle"
                android:layout_toRightOf="@id/searchnow" >

                <com.drona.custom.ImageThumbLayout
                    android:id="@+id/logo"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true" >
                </com.drona.custom.ImageThumbLayout>
            </RelativeLayout>
        </RelativeLayout>

2 个答案:

答案 0 :(得分:0)

  

机器人:layout_width = “FILL_PARENT”

你可以试着改变这个我猜

答案 1 :(得分:0)

Okk我做了什么..我带了一个Horizo​​ntallScrollView,menyLayout可见且可滚动的假...然后当我必须让它可见时我用滚动视图

scrollTo(int x,iny y);

或者我可以做什么我将在mainGridLayout上面添加菜单,即将另一个子节点添加到mainGridLAyout的父节点