0

I am using a sliding drawer on my application (actually its a Panel). I would like to make that panel scrollable. How can I do that?

Here is the xml code for that part:

  <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>
phedon rousou
  • 1,740
  • 5
  • 17
  • 24
  • we're going to need more info to be able to help you. Perhaps post the code for your custom Panel object, and maybe be a little bit more clear about what you are hoping to achieve. "I want to make that panel scrollable" doesn't really give us a lot to go from. – FoamyGuy Apr 04 '12 at 18:23
  • Is the acceptable answer compatible with Android 6.0? – Ahmed Faisal Dec 22 '15 at 20:37

1 Answers1

1

To do what you are looking for is simple. You will want to wrap your TextView @+id/panelContent inside of a ScrollView. This will allow the content inside the open SlidingDrawer to be scrolled. Here is the code for what you are looking to do.

<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>
Bobbake4
  • 24,509
  • 9
  • 59
  • 94
  • what does the fillViewport do? – phedon rousou Apr 04 '12 at 18:47
  • fillViewport causes the content inside of the scrollview to be stretched to fill the area of the scrollview. This will only make a difference if the content is not large enough to actually fill the scrollview. – Bobbake4 Apr 04 '12 at 18:49
  • (Edit) Thanks for your answer. Basically, before applying the change you propose, I have access to the textView through this code: `TextView tv = (TextView) directionPanel.getContent();` And I use tv.setText to set the text to whatever I want. But now, the panelContent is a scrollview, How can I set the textView text? – phedon rousou Apr 04 '12 at 19:10
  • You want to give the TextView a new id and you can use your normal call to findViewById(int id) to get a reference to the TextView so you can set the text on it. – Bobbake4 Apr 04 '12 at 19:46