Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Panel in android?

Tags:

android

panel

I want to add a panel in android activity.I'll try explain its behaviour.

It should show small arrow on right side of my activity, If i click on that a panel having few buttons should slide out consuming around 20%-30% of current activity.

Somewhat same like menu appears on screen.

Thanks in advance.

like image 212
Harshad Avatar asked Mar 10 '11 09:03

Harshad


2 Answers

See the SlidingDrawer widget. However, this widget will only slide up and down on older SDK versions.

Else, you should consider using fragments (using the compatibility API if necessary). You can look for some explanations about how the GMail app is built, or the HoneyComb gallery example to get information about animating fragments.

like image 107
Vincent Mimoun-Prat Avatar answered Oct 16 '22 16:10

Vincent Mimoun-Prat


Here is my example of Panel

 <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:background="@drawable/border">
        <TextView
            android:text="@string/panel_title"
            android:id="@+id/groupTitle"
            android:paddingLeft="5dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/blue" />

Here you add panel content...

</LinearLayout>

You also need to add in drawable resource broder.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
  <stroke
       android:width="3dip"
       android:color="#d3d3d3" />
</shape>

And color in values/Colors.xml

<?xml version="1.0" encoding="utf-8" ?>
<resources>
  <item name="blue" type="color">#FF33B5E5</item>
</resources>

And panel Title in values/Strings.xml

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

<resources>
  <string name="panel_title">Panel 1</string>
</resources>

As for button and animation that can be added separatly.

like image 44
Senad Mulaosmanović Avatar answered Oct 16 '22 16:10

Senad Mulaosmanović