Reputation: 2086
I want to give a custom title above my listView
. After reading some threads
here I made the code as follows, but the title bar size is becoming very small, i want to make it a little bigger. Also while scrolling down
the list a big gap is created between the listview
top and title bar. How can I avoid this? Can anybody help me?
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.citylisttitle);
}
Upvotes: 1
Views: 603
Reputation: 1006
Here's how I did it. First, in the manifest set your activity to have no title.
<activity android:name="Detail"
android:label="@string/app_name"
android:theme="@android:style/Theme.Light.NoTitleBar"/>
Then add your custom title bar at the top of the layout.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:id="@+id/detail_titleBar"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/title_bar"
android:layout_alignParentTop="true">
<TextView android:id="@+id/detail_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:textSize="18sp"
android:textColor="@android:color/white"/>
</LinearLayout>
<ListView android:id="@+id/detail_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/detail_titleBar"
android:layout_above="@+id/detail_iconbar"/>
<LinearLayout android:id="@+id/detail_iconbar"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@android:drawable/bottom_bar"
android:gravity="center_vertical">
....
Upvotes: 3