Customize The Title Bar in Android
Rabu, 23 Januari 2013
0
komentar
main.xml:
< ?xml version="1.0" encoding="utf-8"?>
< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/titlebar>
< TextView
style="@style/MyRedTextAppearance"
android:padding="7dp"
android:id="@+id/txtvew_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#FFFFFF"
android:textSize="20dp"
android:textStyle="bold"
android:gravity="center"/>
< /LinearLayout>
Include the above xml to the main xml as given below...
in java class:
< RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/redbg" >
< include
android:id="@+id/head"
layout="@layout/titlebaar" />
< LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/head"
android:padding="5dp" >
--- ---- --- ---- --- --- -- --
--- --- ---- --- --- --- --- --
< /LinearLayout>
< /RelativeLayout>
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.show_image);
TextView t1 = (TextView) findViewById(R.id.txtvew_title);
t1.setText("Custom Title Bar");
t1.setTextColor(Color.RED);
}
0 komentar:
Posting Komentar