列表上方的片​​段

时间:2016-09-26 10:46:51

标签: android android-fragments layout

我想在Fragment上方创建地图ListView。不幸的是,片段几乎都在屏幕上方。视图对于调整片段大小非常重要。如果smbd能为我解释哪个部分不正确?

XML:

<RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fitsSystemWindows="true">

<MapHidder.SlidingUpPanelLayout
            android:id="@+id/slidingLayout"
            android:gravity="bottom"
            app:shadowHeight="0dp"
            app:paralaxOffset="@dimen/paralax_offset"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <FrameLayout
                android:gravity="top"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">

                <fragment xmlns:map="http://schemas.android.com/apk/res-auto"
                    android:id="@+id/map"
                   android:name="com.google.android.gms.maps.SupportMapFragment"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent" />
            </FrameLayout>
            <RelativeLayout
                android:id="@+id/slidingContainer"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">
            <View
                android:id="@+id/transparentView"
                android:visibility="gone"
                android:layout_width="fill_parent"
                android:layout_height="@dimen/map_height"
                android:layout_alignParentTop="true"
             />

            <View
                android:id="@+id/whiteSpaceView"
                android:visibility="gone"
                android:background="@android:color/darker_gray"
                android:layout_marginTop="@dimen/map_height"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>

            <MapHidder.LockableListView
                android:id="@+id/museumList"
                android:cacheColorHint="@android:color/white"
                android:drawSelectorOnTop="true"
                android:dividerHeight="@dimen/divider_height"
                android:divider="@android:color/darker_gray"
                android:background="@android:color/transparent"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:smoothScrollbar="false" />
        </RelativeLayout>
        </MapHidder.SlidingUpPanelLayout>
    </RelativeLayout>

现在我已经获得了这样的enter image description here

更新我尝试将相对布局更改为线性布局,但仍然没有任何变化。

    <LinearLayout 
android:id="@+id/activity_main"
android:orientation="vertical"
android:weightSum="24">
    <MapHidder.SlidingUpPanelLayout
        android:id="@+id/slidingLayout"
        app:shadowHeight="0dp"
        app:paralaxOffset="@dimen/paralax_offset"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="bottom">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:layout_weight="8">
        <FrameLayout
            android:id="@+id/frame"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">

            <fragment xmlns:map="http://schemas.android.com/apk/res-auto"
                android:id="@+id/map"
               android:name="com.google.android.gms.maps.SupportMapFragment"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
        </FrameLayout>
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:layout_weight="16">
        <RelativeLayout
            android:id="@+id/slidingContainer"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/frame">
            <View
                android:id="@+id/transparentView"
                android:visibility="gone"
                android:layout_width="fill_parent"
                android:layout_height="@dimen/map_height"
                android:layout_alignParentTop="true"  />

            <View
                android:id="@+id/whiteSpaceView"
                android:visibility="gone"
                android:background="@android:color/darker_gray"
                android:layout_marginTop="@dimen/map_height"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

            <MapHidder.LockableListView
                android:id="@+id/museumList"
                android:cacheColorHint="@android:color/white"
                android:drawSelectorOnTop="true"
                android:dividerHeight="@dimen/divider_height"
                android:divider="@android:color/darker_gray"
                android:background="@android:color/transparent"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:smoothScrollbar="false" />
        </RelativeLayout>
        </LinearLayout>
    <MapHidder.SlidingUpPanelLayout>
 </LinearLayout>

1 个答案:

答案 0 :(得分:0)

试试这个......

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fitsSystemWindows="true">

    <MapHidder.SlidingUpPanelLayout
        android:id="@+id/slidingLayout"
        app:shadowHeight="0dp"
        app:paralaxOffset="@dimen/paralax_offset"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <FrameLayout
            android:id="@+id/frame"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">

            <fragment xmlns:map="http://schemas.android.com/apk/res-auto"
                android:id="@+id/map"
               android:name="com.google.android.gms.maps.SupportMapFragment"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />

        </FrameLayout>

        <RelativeLayout
            android:id="@+id/slidingContainer"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/frame">
            <View
                android:id="@+id/transparentView"
                android:visibility="gone"
                android:layout_width="fill_parent"
                android:layout_height="@dimen/map_height"
                android:layout_alignParentTop="true"  />

            <View
                android:id="@+id/whiteSpaceView"
                android:visibility="gone"
                android:background="@android:color/darker_gray"
                android:layout_marginTop="@dimen/map_height"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

            <MapHidder.LockableListView
                android:id="@+id/museumList"
                android:cacheColorHint="@android:color/white"
                android:drawSelectorOnTop="true"
                android:dividerHeight="@dimen/divider_height"
                android:divider="@android:color/darker_gray"
                android:background="@android:color/transparent"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:smoothScrollbar="false" />

        </RelativeLayout>
    </MapHidder.SlidingUpPanelLayout>
</RelativeLayout>

希望这会对你有所帮助。