Maclaren
Maclaren

Reputation: 289

Sliding drawer as title

I am trying to make something like a slide down menu, but i also want it to act as a title bar.

I originally wanted to make the title bar be able to slide down and reveal a listView with clickable items. Unfortunately putting a layout in a title bar didn't work out to well.

Instead I decided to make a custom title bar and give it a size of 0,(I didn't want to use the flag FEATURE_NO_TITLE, since it removes the status bar as well)

So far i have something that slides down, but does not match the parent width. The layout of the textView that makes it slidable does not align to the left. I would like to figure out how to make the background a different colour, of the entire "sliding drawer"

i need help with:

  1. match text view to parent width
  2. Align text view to Left
  3. Change colour of the panel that slides down

Thanks for any help

In my Main activity i am just setting the title to a custom title, and the content view to the following XML.

<SlidingDrawer xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/slidingDrawer"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:content="@+id/content"
android:gravity="center_horizontal"
android:handle="@+id/handle"
android:orientation="vertical"
android:rotation="180" >

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

    <TextView 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:rotation="180"
        android:paddingTop="5dp"
        android:paddingBottom="5dp"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Pull Here"/>
</LinearLayout>

<ImageView
    android:id="@+id/content"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#FF0000"
    android:rotation="180"
    android:src="@drawable/ic_launcher" />

Upvotes: 0

Views: 240

Answers (2)

LvN
LvN

Reputation: 711

I suggest you to try the SlidingMenu library. You can find it here

Upvotes: 2

Srikanth
Srikanth

Reputation: 2114

Looks like you are reinventing the wheel. There are many perfectly functional sliding-drawer libraries available. You can practically have a drawer slide from top, left, right or bottom and even have them in crazy awesome locations like in a listview row.

Have a look at the app - Libraries for Developers, which lists out every library along with demos & github links. Its better if you choose one and customize it to your needs.

Upvotes: 0

Related Questions