android, Tutorial 030, UI, customer Title Bar
below code we will create app like it.
<pre>package com.powenko.Tutorial_CustomTitle; import android.app.Activity; import android.os.Bundle; import android.view.Window; import android.widget.ProgressBar; import android.widget.TextView; public class Tutorial_CustomTitleActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.main ); if (customTitleSupported) { getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.maintitle); TextView tv = (TextView) findViewById(R.id.tv); tv.setText("Powenko.com"); ProgressBar titleProgressBar = (ProgressBar) findViewById(R.id.PB); //titleProgressBar.setVisibility(ProgressBar.GONE); } } }</pre>
res\layout\main.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="httpss://schemas.android.com/apk/res/android">. <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Powen" android:textColor="@drawable/white" android:textStyle="bold" > </TextView> </RelativeLayout>
res\layout\main.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="httpss://schemas.android.com/apk/res/android">. <ImageView android:layout_width="40dip" android:id="@+id/ImageView01" android:background="@drawable/icon" android:layout_height="40dip" > </ImageView> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/tv" android:text="CoderzHeaven" android:layout_toRightOf="@+id/ImageView01" android:textColor="@drawable/red" android:textStyle="bold" android:layout_marginLeft="5dip" android:layout_marginRight="5dip"> </TextView> <ProgressBar android:id="@+id/PB" style="?android:attr/progressBarStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toRightOf="@+id/tv" android:paddingLeft="3dip"> </ProgressBar> </RelativeLayout>
res\values\strings.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, Tutorial_CustomTitleActivity!</string> <string name="app_name">Tutorial_CustomTitle</string> <drawable name="white">#ffffff</drawable> <drawable name="black">#000000</drawable> <drawable name="blue">#2554C7</drawable> <drawable name="green">#347C2C</drawable> <drawable name="orange">#ff9900</drawable> <drawable name="pink">#FF00FF</drawable> <drawable name="violet">#a020f0</drawable> <drawable name="grey">#778899</drawable> <drawable name="red">#C11B17</drawable> <drawable name="yellow">#FFFF8C</drawable> <drawable name="PowderBlue">#b0e0e6</drawable> <drawable name="brown">#2F1700</drawable> </resources>