Adnan
Adnan

Reputation: 26350

Title bar in Android

My class extends a ListActivity, I would like to have a title bar just as "Sound settings" in the following image;

enter image description here

What would be the proper way to create such title.

Thank you for your time.

Upvotes: 0

Views: 187

Answers (2)

Hein
Hein

Reputation: 2683

Creating custom layout can solve this problem.

<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout  
  xmlns:android="http://schemas.android.com/apk/res/android"  
  android:layout_width="match_parent"  
  android:layout_height="match_parent">  
  android:orientation="vertical"  
    <TextView android:id="@+id/textViewCategoriesTitle"  
              android:layout_width="fill_parent"  
              android:layout_height="wrap_content"  
              android:text="@string/categoriesTitle"  
              android:background="#123"  
              android:layout_gravity="center_horizontal"  
              android:textSize="30sp" />  

    <ListView android:layout_height="wrap_content"  
              android:layout_width="fill_parent"  
              android:id="@+id/listViewCategories"  
              android:layout_gravity="center_vertical|center_horizontal" />  

</LinearLayout>  

Hope this can help.

Upvotes: 3

Gregory
Gregory

Reputation: 4424

You could add a header view to the list view :

getListView().addHeaderView(myTitleView);

I'm not sure how you can be sure to get the exact same look, though. I would try with just a basic layout containing a TextView and see how that works out.

Upvotes: 2

Related Questions