2012-04-04 3 views
0

私は自分のアプリケーション(実際にはパネル)にスライド式の引き出しを使用しています。私はそのパネルをスクロール可能にしたいと思います。どうやってやるの?ここでAndroid:Sliding Drawer

は、その部分のためのXMLコードです:あなたが探しているものを行うには

<org.miscwidgets.widget.Panel 
     android:id="@+id/rightPanel3" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_gravity="right" 
     panel:animationDuration="500" 
     panel:closedHandle="@android:drawable/ic_menu_directions" 
     panel:content="@+id/panelContent" 
     panel:handle="@+id/panelHandle" 
     panel:linearFlying="true" 
     panel:openedHandle="@android:drawable/ic_menu_directions" 
     panel:position="right" 
     panel:weight="75%p" > 

     <Button 
      android:id="@+id/panelHandle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_marginBottom="20dip" /> 

     <TextView 
      android:id="@+id/panelContent" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:background="#000000" 
      android:gravity="left" 
      android:padding="4dip" 
      android:text="Directions" 
      android:textColor="#eee" 
      android:textSize="16dip" 
      android:textStyle="bold" /> 
    </org.miscwidgets.widget.Panel> 
+0

私たちはあなたを助けるためにもっと多くの情報が必要です。おそらく、あなたのカスタムPanelオブジェクトのコードを投稿して、あなたが達成しようとしていることについてもう少し明確にしてください。 「私はそのパネルをスクロール可能にしたい」ということは、本当に私たちに多くのものを与えてくれるものではありません。 – FoamyGuy

+0

許容される回答はAndroid 6.0と互換性がありますか? – Ahmed

答えて

1

は簡単です。 TextView @ + id/panelContentをScrollView内にラップしたいと思うでしょう。これにより、開いているSlidingDrawer内のコンテンツをスクロールすることができます。ここであなたが探しているもののコードです。

<org.miscwidgets.widget.Panel 
    android:id="@+id/rightPanel3" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:layout_gravity="right" 
    panel:animationDuration="500" 
    panel:closedHandle="@android:drawable/ic_menu_directions" 
    panel:content="@+id/panelContent" 
    panel:handle="@+id/panelHandle" 
    panel:linearFlying="true" 
    panel:openedHandle="@android:drawable/ic_menu_directions" 
    panel:position="right" 
    panel:weight="75%p" > 

    <Button 
     android:id="@+id/panelHandle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_marginBottom="20dip" /> 

    <ScrollView 
     android:id="@+id/panelContent" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     andrid:fillViewport="true" > 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="fill_parent" 
       android:background="#000000" 
       android:gravity="left" 
       android:padding="4dip" 
       android:text="Directions" 
       android:textColor="#eee" 
       android:textSize="16dip" 
       android:textStyle="bold" /> 
    </ScrollView> 
</org.miscwidgets.widget.Panel> 
+0

fillViewportは何をしますか? –

+0

fillViewportは、スクロールビュー内のコンテンツをスクロールビューの領域を埋めるように引き延ばします。コンテンツがスクロールビューを実際に満たすのに十分な大きさでない場合、これは違いになります。 – Bobbake4

+0

(編集)あなたの答えをありがとう。基本的には、あなたが提案する変更を適用する前に、私はこのコードを通してtextViewにアクセスできます: 'TextView tv =(TextView)directionPanel.getContent();'そして、tv.setTextを使ってテキストを設定します。しかし、今、panelContentはスクロールビューです。どうすればtextViewテキストを設定できますか? –

関連する問題