The example in this article describes the method for Android programming to customize title bar (title bars). Share to everyone for your reference, specific as follows:
Package com.test;
Import android.app.Activity;
Import Android.content.Context;
Import Android.graphics.Canvas;
Import Android.graphics.Color;
Import android.graphics.drawable.Drawable;
Import Android.os.Bundle;
Import Android.view.View;
Import Android.view.Window;
Import android.view.animation.Animation;
Import android.view.animation.TranslateAnimation;
Import Android.widget.ProgressBar;
Import Android.widget.TextView;
The public class Test extends activity {/** Called when the ' activity is ' A-a-created Boolean customtitlesupported;
public void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);
Check if custom title is supported before setting the content view!
customtitlesupported = Requestwindowfeature (Window.feature_custom_title);
Setcontentview (R.layout.main);
Set Custom TitleBar Customtitlebar (GetText (r.string.app_name). ToString (), "Hello world!!"); public void Customtitlebar (string left, string right) {if (Right.lengTh () >) right = right.substring (0, 20); Set up custom title if (customtitlesupported) {GetWindow (). Setfeatureint (Window.feature_custom_title, r.layout.t
Itle);
TextView titletvleft = (TextView) Findviewbyid (r.id.titletvleft);
TextView titletvright = (TextView) Findviewbyid (r.id.titletvright);
Titletvleft.settext (left);
Titletvright.settext (right);
ProgressBar Titleprogressbar;
Titleprogressbar = (ProgressBar) Findviewbyid (R.id.leadprogressbar);
Hide the progress bar if it is not needed titleprogressbar.setvisibility (Progressbar.gone);
}
}
}
Layout file: Title.xml
<?xml version= "1.0" encoding= "Utf-8"?> <relativelayout "android:id=" RelativeLayout01 "android:layout_width=" fill_parent "android:layout_height=" fill_parent "xmlns:android=" http:// Schemas.android.com/apk/res/android "> <textview android:layout_width=" wrap_content "android:layout_height=" Wrap_content "android:id=" @+id/titletvleft "android:text=" left "></TextView> <textview android:layout_ Width= "Wrap_content" android:layout_height= "wrap_content" android:id= "@+id/titletvright" android:text= "right"
Android:layout_alignparentright= "true" ></TextView> <progressbar android:id= "@+id/leadprogressbar" Style= "Android:attr/progressbarstylesmall" android:layout_width= "wrap_content" android:layout_height= "Wrap_ Content "Android:layout_centervertical=" true "android:layout_torightof=" @+id/titletvleft "android:paddingleft=" 3dip "></ProgressBar> </RelativeLayout>
For more information on Android-related content readers can view the site: "Android View tips Summary", "Android Layout Layout Skills Summary", "Android Development introduction and Advanced Course", " Android Debugging tips and FAQ Solutions Summary, Android Multimedia tips summary (audio, video, audio, etc.), "Android Basic Components Usage Summary" and "Android Control usage Summary"
I hope this article will help you with the Android program.