android 語言, 教學文件 021-1-1, UI, 使用設計 Title Bar

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

Android
CH01 簡介篇CH02 開發設定CH03 Android 軟體評論CH04 UICH05Android studioCH09 資料庫databaseCH10 系統篇CH11 多執行序和時間 ThreadTimerCH29 APICH30 Android 技術文章CH50 Android IOIO