ActionBar學習筆記

ActionBar 相關的layout 文件如下:
(1)窗口ActionBarOverlayLayout(decor_content_parent),包括ActionBarContainer和主體abc_screen_content_include
(2)ActionBarContainer(action_bar_container) 會包含Toolbar(action_bar) 及當創建了菜單後的ActionBarContextView(action_context_bar), 後者是創建的ActionMode 上下文菜單.
(3)無論是Toolbar 還是ActionBarContextView(即ActionMode 菜單), 需要關注的是其style: actionBarStyle & actionModeStyle.
各自APP 可以繼承Google原生的Theme並根據實際情況覆寫自己的需要的部分.
 
<android.support.v7.internal.widget.ActionBarOverlayLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/decor_content_parent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">

    <include layout="@layout/abc_screen_content_include"/>

    <android.support.v7.internal.widget.ActionBarContainer
            android:id="@+id/action_bar_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            style="?attr/actionBarStyle"
            android:touchscreenBlocksFocus="true"
            android:gravity="top">

        <android.support.v7.widget.Toolbar
                android:id="@+id/action_bar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:navigationContentDescription="@string/abc_action_bar_up_description"
                style="?attr/toolbarStyle"/>

        <android.support.v7.internal.widget.ActionBarContextView
                android:id="@+id/action_context_bar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:visibility="gone"
                android:theme="?attr/actionBarTheme"
                style="?attr/actionModeStyle"/>

    </android.support.v7.internal.widget.ActionBarContainer>

</android.support.v7.internal.widget.ActionBarOverlayLayout>


ActionBar 樣式可以參考:

http://blog.csdn.net/sunyouhao/article/details/7862017

 

ActionMode樣式可以參考:

http://blog.csdn.net/xdyuchen/article/details/50950972

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章