2011-10-26 76 views
3

我正在構建一個Android應用程序,該應用程序目前由若干活動組成,每個活動都包含一個自定義的LinearLayout頂部的標題欄。更改活動時防止標題欄動畫

當我更改活動時,默認動畫會導致整個頁面滑動,而理想情況下,我希望標題欄保持靜態。由於標題欄通常在多個頁面中包含相同的文本,動畫似乎不必要。

Spotify的Android應用程序就是我所說的完美例子。如果您導航到「更多」,然後點擊「設置」,頁面內容會滑過,但標題欄不會。

如果有人有任何見解,將不勝感激!

標題欄佈局:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="35dp" 
android:gravity="center_vertical" 
android:orientation="horizontal" 
android:background="@layout/bg_menubar" 
android:paddingLeft="14dp"> 

<TextView android:text="APP_NAME" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textColor="#ffffff" 
    android:textStyle="bold" 
    android:shadowColor="#231f20" 
    android:shadowRadius="1.6" 
    android:shadowDx="1.5" 
    android:shadowDy="1.3" /> 

<ImageView android:layout_width="1px" 
    android:layout_height="fill_parent" 
    android:background="#00113a" 
    android:layout_marginLeft="14dp" />  
<ImageView android:layout_width="1px" 
    android:layout_height="fill_parent" 
    android:background="#8b979f" 
    android:layout_marginRight="14dp" /> 

<TextView android:id="@+id/tv_title" 
    android:text="Dashboard" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textColor="#ffffff" 
    android:textStyle="bold" 
    android:shadowColor="#231f20" 
    android:shadowRadius="1.6" 
    android:shadowDx="1.5" 
    android:shadowDy="1.3" /> 
</LinearLayout> 
+0

Android的內置ViewFlipper類似乎是一個很好的方法。這樣我可以將類似的「頁面」捆綁到一個活動中。儘管如此,知道這是否可以用單獨的活動也是有趣的! – Preyes

回答

1

而最好我想標題欄留靜態

這是不可能的,對不起。

Spotify的Android應用程序就是我的意思的完美例子。如果您導航到「更多」,然後點擊「設置」,頁面內容會滑過,但標題欄不會。

那些不是多個活動,那麼。正如@Preyes所示,他們可能使用ViewFlipper