• Android AppBar滑动模板


    仅供参考

    XML布局

    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="250dp">
    
            <android.support.design.widget.CollapsingToolbarLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:contentScrim="?attr/colorPrimary"
                app:layout_scrollFlags="scroll|exitUntilCollapsed"
                app:layout_scrollInterpolator="@android:anim/decelerate_interpolator"
                app:toolbarId="@+id/toolbar">
    
                <ImageView
                    android:id="@+id/app_bar_image"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scaleType="centerCrop"
                    android:src="@drawable/image3"
                    app:layout_collapseMode="parallax" />
    
                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="80dp">
                </android.support.v7.widget.Toolbar>
    
            </android.support.design.widget.CollapsingToolbarLayout>
    
        </android.support.design.widget.AppBarLayout>
    
        <android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior">
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:paddingBottom="100dp">
                
                <!-- 此处为随动列表 -->
    
            </LinearLayout>
        </android.support.v4.widget.NestedScrollView>
    
    </android.support.design.widget.CoordinatorLayout>
    
    <menu xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto">
        <item
            android:id="@+id/item_exp1"
            android:title="temp1"/>
        <item
            android:icon="@drawable/ic_share"
            android:title="share"
            android:id="@+id/item_exp2"
            app:showAsAction="always"/>        //常显示
        <item
            android:id="@+id/item_exp3"
            android:title="temp2"/>
        <item
            android:title="temp3"
            android:id="@+id/item_exp4"/>
    
    </menu>
    

    代码

    设置toolbar

    setContentView(R.layout.activity_first);
    

    后添加

    Toolbar toolbar;
    toolbar = (Toolbar)findViewById(R.id.toolbar);
    toolbar.setTitle("Welcome");
    toolbar.setSubtitle("It`s my little app.");
    
    
            Toolbar.OnMenuItemClickListener menuItemClick = new Toolbar.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    int id = item.getItemId();
                    switch (id){
                        case R.id.item_exp1:
                            //
                            break;
                        case R.id.item_exp2:
                           //
                            break;
                        case R.id.item_exp3:
                            //
                            break;
                        case R.id.item_exp4:
                            //
                            break;
                    }
                    return false;
                }
            };
    
    toolbar.setOnMenuItemClickListener(menuItemClick);        //放置menu
    toolbar.inflateMenu(R.menu.settings);
    
  • 相关阅读:
    bugKu getshell
    XCTF 进阶区 CAT
    php弱类型比较
    XCTF command_execution
    关于错误 openssl/ssl.h:没有那个文件或目录的解决办法
    libffi-dev : 依赖: libffi6 (= 3.2.1-4) 但是 3.2.1-4kord 正要被安装
    如何查看 Ubuntu下已安装包版本号
    git 下载指定tag版本的源码
    ubuntu 环境 openstack 源码包制成 deb 包
    fedora 国内源
  • 原文地址:https://www.cnblogs.com/Mr-quin/p/8583507.html
Copyright © 2020-2023  润新知