d0085505_4acd33671d143

FROM : http://skyswim42.egloos.com/3354981

 

使用者可以修改title bar   
 
一個簡單的示例:
 
1. 在onCreate 
 
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
            
        setContentView(R.layout.main);  // setContentView 必須在此位置,正常的行為並不一定。.
            
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
 
// 使用者定義 title bar
        imageview = (ImageView)findViewById(R.id.favicon);
        textview2 = (TextView)findViewById(R.id.right_text);
        progress1 = (ProgressBar)findViewById(R.id.progress2);
            
        imageview.setImageResource(R.drawable.app_web_browser_sm);
 
 
2. custom_title.xml
 
 
<?xml version="1.0" encoding="utf-8"?>
 
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/screen" android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
 
    <ImageView android:id="@+id/favicon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:scaleType="center" />
   
 
<ProgressBar android:id="@+id/progress2"
            style="?android:attr/progressBarStyleHorizontal"
            android:gravity="center_vertical"
            android:paddingRight="5dip"
            android:layout_width="200dip"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/favicon"/>
        
    <TextView android:id="@+id/right_text"
        android:gravity="center_vertical"
        style="?android:attr/windowTitleStyle"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent" android:paddingRight="5dip"
        android:layout_toRightOf="@id/favicon"/>
 
 
<ImageButton 
android:id="@+id/stop"
android:layout_width="30dip"
        android:layout_height="fill_parent"
        android:src="@drawable/icon"
        android:layout_toRightOf="@id/progress2"
        />
 
</RelativeLayout>
 
 
arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()