【问题标题】:How to stop main content re-sizing of umano AndroidSlidingUpPanel when panel is set to default panel height当面板设置为默认面板高度时,如何停止 umano AndroidSlidingUpPanel 的主要内容重新调整大小
【发布时间】:2014-02-20 10:54:43
【问题描述】:

我在我的 Android 项目中使用 umano AndroidSlidingUpPanel。这里我使用谷歌地图作为我的主要内容。以下是相关的 XML 文件。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".DemoActivity" >

    <com.mypkg.name.SlidingUpPanelLayout
        xmlns:sothree="http://schemas.android.com/apk/res-auto"
        android:id="@+id/sliding_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="bottom"
        sothree:collapsedHeight="78dp"
        sothree:dragView="@+id/linLayout"
        sothree:shadowHeight="4dp" >

        <FrameLayout
            android:id="@+id/activity_single_fragment_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#0000FF" >

            <fragment
                android:id="@+id/map_fragment"
                android:name="com.google.android.gms.maps.SupportMapFragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </FrameLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#eee"
            android:clickable="true"
            android:focusable="false"
            android:orientation="vertical" >

            <RelativeLayout
                android:id="@+id/drawerListItemProfile_relativeLayout"
                android:layout_width="match_parent"
                android:layout_height="80dp"
                android:background="@drawable/drawer_profile_selector" >

                <FrameLayout
                    android:id="@+id/imgFrameLayout"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:layout_margin="5dp" >

                    <ImageView
                        android:id="@+id/drawerListItemProfile_imageView"
                        android:layout_width="@dimen/nav_profile_circle_size"
                        android:layout_height="@dimen/nav_profile_circle_size"
                        android:contentDescription="@string/contentDescription_drawer_profile_pic"
                        android:scaleType="centerCrop"
                        android:src="@drawable/profilepic" />
                </FrameLayout>
            </RelativeLayout>

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:scaleType="fitStart"
                android:src="@null" >
            </ImageView>
        </LinearLayout>
    </com.mypkg.name.SlidingUpPanelLayout>

</RelativeLayout>

但是当 Activity 开始时,我将面板的默认高度设置为 0。

slidingUpPanelLayout.setPanelHeight(0);

当点击地图上的标记时,我将面板设置为默认高度。

slidingUpPanelLayout.setPanelHeight(defaultPanelHeight);

再一次,当我点击地图(不是在标记上)时,面板高度设置为 0。当我这样做时,地图正在重新调整大小。我怎么能阻止它。我希望此功能与 Android 移动设备中的 Google 地图一样工作。

【问题讨论】:

    标签: android android-xml slidingdrawer android-sliding bottom-up


    【解决方案1】:

    Bazinga ;) 我做到了。

    只需在 (https://github.com/umano/AndroidSlidingUpPanel/blob/master/library/src/com/sothree/slidinguppanel/SlidingUpPanelLayout.java) 中评论 495 行即可;

    height -= panelHeight;
    

    你可以走了。但是,如果您使用 Google Maps 放大缩小按钮,您可能会遇到问题。也就是说,向上滑动的抽屉将覆盖这些按钮。但在真正的 Google 地图中不会发生。

    【讨论】:

    • 非常感谢您!你知道是否有可能让它成为一个滑动动画而不是仅仅弹出?就像在 GoogleMaps 中一样?
    • @deimos1988 没试过。如果我愿意,我会更新这个帖子。
    • 我问了一个与此有关的问题 (stackoverflow.com/questions/22616605/…),如果您认为您可能有解决方案,我们将非常感谢您的回答!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-03
    • 2014-04-14
    • 1970-01-01
    • 1970-01-01
    • 2013-02-19
    • 2017-10-20
    相关资源
    最近更新 更多