2013-02-05 88 views
0

我想要一個滑動抽屜,它顯示在我的視圖底部,但它目前不顯示。我也嘗試使用線性佈局作爲根,滾動視圖的權重爲1,但導致滾動視圖及其內容不顯示。有任何想法嗎?滑動抽屜不顯示

筆者認爲:

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

<ScrollView 
    android:id="@+id/scrollLayout" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     tools:context=".AddScheduleItemActivity" > 

     . 
     . 
     . 

    </LinearLayout> 
</ScrollView> 

<SlidingDrawer 
    android:id="@+id/slidingDrawer1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/scrollLayout" 
    android:content="@+id/content" 
    android:handle="@+id/handle" > 

    <Button 
     android:id="@+id/handle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Handle" /> 

    <LinearLayout 
     android:id="@+id/content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <Button 
      android:id="@+id/hadsfndle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="sdf" /> 
    </LinearLayout> 
</SlidingDrawer> 

感謝, 彌敦道

How it should look

在我想要的藍色是滾動視圖和內容,綠色是圖片滑塊的手柄。

嘗試了下面的一些其他建議,但仍然無法正常工作。 scrollview的內容顯示正常,但滑塊未顯示。需要更多的建議!謝謝!

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:layout_gravity="bottom" 
android:gravity="bottom" 
android:orientation="vertical" > 

<ScrollView 
    android:id="@+id/scrollLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     . 
     . 
     . 

    </RelativeLayout> 
</ScrollView> 

<SlidingDrawer 
    android:id="@+id/slidingDrawer1" 
    android:layout_width="match_parent" 
    android:layout_height="50dip" 
    android:layout_alignParentBottom="true" 
    android:layout_below="@+id/scrollLayout" 
    android:content="@+id/content" 
    android:handle="@+id/handle" 
    android:orientation="vertical" > 

    <Button 
     android:id="@+id/handle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Handle" /> 

    <LinearLayout 
     android:id="@+id/content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <Button 
      android:id="@+id/hadsfndle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="sdf" /> 
    </LinearLayout> 
</SlidingDrawer> 

</RelativeLayout> 

那麼看來滑動抽屜不再受支持,所以我想我會尋找一個替代:(

+0

能否請你讓我確切地知道你希望你的滑蓋的?在屏幕的底部還是屏幕的頂部?我已經測試過您的佈局,並在底部顯示滑塊,並從下到上打開。 – GrIsHu

+0

我想要在底部。對於我發佈的佈局,您可能會看到滑塊,因爲線性佈局中沒有任何內容。添加一堆元素,直到它們超出屏幕上的空間。此時,滾動視圖將滑塊手柄推離屏幕。 – Nath5

回答

0

試試這個,

SlidingDrawer添加layout_alignParentBottom

android:layout_alignParentBottom="true" 
+0

不幸的是沒有工作。任何其他想法? – Nath5

+0

你能顯示屏幕嗎?你想如何 – MuraliGanesan

1

您正試圖在底部顯示您的sliderdrawar,請嘗試以下代碼:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 

    <ScrollView 
     android:id="@+id/scrollLayout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <LinearLayout 
      android:id="@+id/layout" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 


     </LinearLayout> 
    </ScrollView> 

    <LinearLayout 
     android:id="@+id/LinearLayout01" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_below="@+id/layout" 
     android:orientation="vertical" > 

     <SlidingDrawer 
      android:id="@+id/SlidingDrawer" 
      android:layout_width="wrap_content" 
      android:layout_height="250dip" 
      android:content="@+id/contentLayout" 
      android:handle="@+id/slideHandleButton" 
      android:padding="10dip" > 

      <Button 
       android:id="@+id/slideHandleButton" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/ic_launcher" > 
      </Button> 

      <LinearLayout 
       android:id="@+id/contentLayout" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="#C0C0C0" 
       android:gravity="center|top" 
       android:orientation="vertical" 
       android:padding="10dip" > 

       <Button 
        android:id="@+id/Button01" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Content" > 
       </Button> 

       <Button 
        android:id="@+id/Button02" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Content" > 
       </Button> 

       <Button 
        android:id="@+id/Button03" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Content" > 
       </Button> 
      </LinearLayout> 
     </SlidingDrawer> 
    </LinearLayout> 

</RelativeLayout> 

如果上面的代碼沒有解決您的問題,那麼更改父級佈局爲LinearLayout給,然後在您的scrollview & sliderDrawer之間分配等於。

+0

這些選項都沒有工作:( – Nath5

0

也許你的問題已經回答here

試試這個:

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

<ScrollView 
    android:id="@+id/scrollLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     . 
     . 
     . 

    </RelativeLayout> 
</ScrollView> 

<SlidingDrawer 
    android:id="@+id/slidingDrawer1" 
    android:layout_width="match_parent" 
    android:layout_height="50dip" 
    android:layout_alignParentBottom="true" 
    android:content="@+id/content" 
    android:handle="@+id/handle" 
    android:orientation="vertical" > 

    <Button 
     android:id="@+id/handle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Handle" /> 

    <LinearLayout 
     android:id="@+id/content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <Button 
      android:id="@+id/hadsfndle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="sdf" /> 
    </LinearLayout> 
</SlidingDrawer> 

</RelativeLayout>