android, Tutorial 030, UI, customer Title Bar

August 13, 2011   ·   1 Comments

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="http://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>

&nbsp;

&nbsp;

</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="http://schemas.android.com/apk/res/android">.

&nbsp;

<ImageView android:layout_width="40dip"

android:id="@+id/ImageView01"

android:background="@drawable/icon"

android:layout_height="40dip"

>

&nbsp;

</ImageView>

&nbsp;

<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>

&nbsp;

<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"

&nbsp;

android:paddingLeft="3dip">

&nbsp;

</ProgressBar>

&nbsp;

</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>

&nbsp;

</resources>

source code:


Tutorial_CustomTitleActivity  , download here http://code.google.com/p/powenko-android-tutorial/

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (1)

  1. android apps and games

    Wow…you are definately a talented blogger ! Keep up the good work !

    »

You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Android7

Amazon

adsbygoogle

Recent Posts

Categories

Amazon