简体   繁体   English

停止SlidingPaneLayout移得太远

[英]Stop SlidingPaneLayout from going too far

I have a SlidingPaneLayout which contains a fragment in the left hand pane. 我有一个SlidingPaneLayout在左侧窗格中包含一个片段。

<android.support.v4.widget.SlidingPaneLayout 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=".MainActivity$DummySectionFragment"
    >

    <fragment
        android:name="com.bolldorf.cnpmoebel.widgets.PlaceChooserFragment"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/fragment_place_chooser"
        tools:layout="@layout/fragment_place_chooser"
        android:layout_weight="0.3" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">
    < ... more stuff here ... >
        </RelativeLayout>


</android.support.v4.widget.SlidingPaneLayout>

The fragment is not very wide, but it's width can change a little as it consists of dynamically loaded spinners. 片段不是很宽,但是它的宽度可以改变,因为它由动态加载的微调器组成。

How can I get the SlidingPaneLayout to stop opening once it shows the full fragment? 一旦显示完整的片段,如何使SlidingPaneLayout停止打开?

Clarification: Before the panel is slid out, I can see the whole of the right-hand (or bottom in the xml) pane, and the left-hand pane is hidden. 说明:在面板滑出之前,我可以看到整个右侧窗格(或xml底部),而左侧窗格是隐藏的。

After sliding, I can see about 10% of the right-hand pane as it is moved right, and 90% of the left-hand pane. 滑动后,向右移动时,我可以看到大约10%的右窗格,以及90%的左窗格。

What I would like is to see 30% of the left hand pane, and 60% of the right-hand pane, ie I would like the slide movement to stop sooner. 我想看到的是左侧窗格的30%和右侧窗格的60%,即我希望幻灯片运动尽快停止。

可以通过在xml的片段标记中设置“ android:layout_marginLeft”来解决,希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM