• design


    CoordinatorLayout :
    他是一个协调布局他extends ViewGroup implements NestedScrollingParent他应该只能协调跟NestedScrollingParent有关的 例如:NestedScrollView就是implements NestedScrollingParent


    AppBarLayout: 是一个LinearLayout
    CollapsingToolbarLayout: 继承 FrameLayout
    属性:contentScrim折叠后导航条颜色statusBarScrim折叠后状态栏颜色(低版本无效,可能需要4.4后),可设置标题通过title折叠后也可显示
    expandedTitle开头的属性是设置标题展开时候的一些属性,比如,margin,color,位置等,
    expandedTitle则相反是折叠后的,例如:app:expandedTitleGravity="center"是展开后标题位于中间,app:collapsedTitleGravity="center"是折叠后位于toolbar中间

    Toolbar:是一个ViewGroup
    layout_collapseMode最重要属性之一:他的pin模式是折叠后显示toolbar,其他还有两种,没仔细看,这个最长见,
    添加toolbar的子view可以在菜单中添加,其中app:showAsAction分为几种状态(最常用的):always无论是否能放下都展示在ToolbarifRoom如果能放下就展开never从不展开

    如果不总是展示, 最右侧会有一个图标点击后弹出一弹窗就是他的剩余菜单,当然要想改这个图标可以使用
    toolbar.setOverflowIcon(getResources().getDrawable(R.mipmap.ic_launcher));
    当然如果要显示必须要设置setSupportActionBar(toolbar);
    然后从写
    /*创建菜单弹窗*/
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
    }
    R.menu.menu_main需要在res文件下创建menu文件夹,在创建一个menu_main.xml文件
    文件大概这么写
    <menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".MainActivity">
    <item android:id="@+id/action_notifications"
    android:title="Notifications"
    android:icon="@mipmap/ic_notifications"
    app:showAsAction="ifRoom"/>
    </menu>
    /*菜单点击条目*/
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
    return true;
    }
    return super.onOptionsItemSelected(item);
    }
    左侧图标
    toolbar.setNavigationIcon(R.mipmap.ic_drawer_home);
    //左侧点击
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
    Toast.makeText(getApplicationContext(),"左边菜单",Toast.LENGTH_SHORT).show();
    }
    });

    FloatingActionButton:是一个浮动的Button,当然他的位置需要你指定一个控件让他跟随某个控件一起滑动等layout_anchor固定在那个控件,layout_anchorGravity固定位置backgroundTint背景颜色(低版本无效,可能需要4.4后),点击的时候水波纹颜色
     其中我最疑惑的toolbar停留感谢https://github.com/chenyuAndroid/DesignSupportLibrarySample这个Demo 的作者 原文:http://blog.csdn.net/a553181867/article/details/52871424
  • 相关阅读:
    键盘弹出与隐藏对TextView的影响
    iOS9 警告框
    计时器的写法
    iOS提交被拒
    新生活
    批量删除wps文档里的回车符的方法!WPS使用技巧分享!
    学习笔记计划
    监控服务器的注册及登陆并邮件通知的代码(go / python)
    Python调用C代码
    导入用户到Discuz论坛
  • 原文地址:https://www.cnblogs.com/lizhanqi/p/6893969.html
Copyright © 2020-2023  润新知