2012-01-25 7 views
0

私は下から上の構造を持つSlidingDrawerを使用しようとしています。私はスライド式の引き出しの内容の中に4つのスピナーを配置しました..そして、私が実行すると、ハンドル(私は画像があります)画面。私はここでXMLを使ってSlidingDrawerの高さを設定する方法は?

が私のxmlレイアウト...

main.xml

<?xml version="1.0" encoding="utf-8"?> 

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical"> 
    <SlidingDrawer 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/drawer" 
     android:handle="@+id/MyHandle" 
     android:content="@+id/MyContent"> 
      <LinearLayout 
       android:id="@+id/MyHandle" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:gravity="bottom" 
       android:orientation="vertical"> 
       <ImageView 
        android:id="@+id/SlideIcon" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:src="@drawable/images"/> 
      </LinearLayout> 
      <FrameLayout 
       android:id="@+id/MyContent" 
       android:layout_width="fill_parent" 
       android:layout_height="200dip" 
       android:orientation="vertical"> 
       <include 
        android:id="@+id/DrawerContent" 
        layout="@layout/spinnerlayout" 
        android:layout_height="wrap_content"/> 
      </FrameLayout> 
    </SlidingDrawer> 
</FrameLayout> 

とspinnerlayout.xmlである(つまり、わずか4つのスピナ上記...)それは単にコンテンツの上に処理したいです...

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:foregroundGravity="bottom" 
    android:layout_gravity="bottom" 
    android:background="@color/grey"> 

    <LinearLayout 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:orientation="vertical"> 
     <Spinner 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/spinner_first"/> 
     <Spinner 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/spinner_second"/> 
     <Spinner 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/spinner_third"/> 
     <Spinner 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/spinner_fourth"/> 
    </LinearLayout> 
</FrameLayout> 

そして、私の質問をより明確にするために、私はスクリーンショットを持っている...

before handle is clicked

after handle is clicked

私はそれがスピナー真上そのハンドル(矢印)を持つようにしたい。..

はそれを配置することは可能ですか?

答えて

3

SlidingDrawerクラスのonMeasure()メソッドは、基本的にfill_parentのレイアウトモードをオーバーライドします。これが、layout_height = "wrap_content"が機能しない理由です。

この問題を回避するには、layout_widthおよびlayout_height属性を尊重する、再実装されたonMeasure()メソッドを使用してSlidingDrawerを拡張できます。その後、このカスタムクラスをXMLレイアウトで使用することができます。

引き出しが親レイアウトを塗りつぶすことはなくなるため、重力属性を引き出しが必要なエッジに設定して、引き出しをLinearLayoutに囲む必要があります。

回答
your Question

+0

私はそれを愛する知っている、onMeasureをオーバーライドから()私は...それを設定することができ、多くの例もあります。しかし、私は高さを設定することが可能かどうかを知るためにこの質問をしていました..あなたは何ですか、それは可能ですか? –

+0

use android:topOffset = "" –

+0

これはもう一つのサンプルです。http://android-journey.blogspot.com/2009/12/android-viewflipper-and-slidingdrawer.html –

関連する問題