1

I want to create the click effect on the following type of custom title Bar.

enter image description here

There are three functions in here:Home,Title and Search, clicking either of it should perform the further function.

I was following this

http://staticallytyped.wordpress.com/2011/03/18/android-dynamic-and-custom-title-bars/

But i want the effect which i have posted above.

Shruti
  • 1
  • 13
  • 55
  • 95

2 Answers2

2

The thing you are talking about is called Action Bar. This is specially designed for Android Tablets. But developers have made Action Bar available for Android Mobile Phones too.

Have a look at Action Bar written by johannilsson. You can simply download this library project and customize according to your need and then integrate this library to your project.

Other Action Bar examples :

Xoriant Action Bar --

Note : THIS IS THE SAME THING THAT YOU WANT as you want to have Home, Search and Title on it.

Thiranjith blogspot

Kartik Domadiya
  • 29,868
  • 19
  • 93
  • 104
  • this action bar can be used on API level 11.will this work for a application which i am developing using API level 2.1 ? – Shruti Jan 07 '12 at 05:21
0

Just try this..

1) First create two layouts like main & custom_title

2) You must include the drawables which type like you've posted here. And, use this code.

main.xml - Just designed whatever you want.

custom_title.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:gravity="center_vertical"
android:paddingLeft="5dip"
android:background="#323331">

<Button
    android:id="@+id/button1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:onClick="hello"
    android:text="Button" />
</LinearLayout>

Main.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

    setContentView(R.layout.main);

    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
}
public void hello(View view)
{
    Toast.makeText(getApplicationContext(), "Hi, this is test.", Toast.LENGTH_LONG).show();
}

Change this code to your needs. Hope this helps you.

Praveenkumar
  • 24,084
  • 23
  • 95
  • 173
  • thanks for replying..but i have tried this but not getting the desired output I am getting the effect as shown in the link i referred..i want to create UI like i the image i shared.. – Shruti Jan 05 '12 at 12:29