The proposed practise for the new navigation components were presented at I/O with the following template and proposed philosophy:

新导航组件的拟议实践在I / O中提供,具有以下模板和建议的理念:

  1. One Activity for an App
  2. 应用程序的一个活动

  3. Activity contains Toolbar and Bottom Navigation Bar
  4. 活动包含工具栏和底部导航栏

A typical app often has a detail view with a CollapsingToolbar in it. How would one build that under that architecture?

典型的应用程序通常具有详细视图,其中包含CollapsingToolbar。如何在该架构下构建它?

  • Move Toolbar to each Fragment XML?
  • 将工具栏移动到每个片段XML?

  • Implement the collapsing toolbar programmatically?
  • 以编程方式实现折叠工具栏?

  • Move the detail fragment to its own activity (it may use its own deeplink anyway) and 'break' the philosophy?
  • 将细节片段移动到它自己的活动(它可能会使用它自己的深层链接)并“打破”这个哲学?

1 个解决方案

#1


0

try

appBarLayout = (AppBarLayout) findViewById(R.id.appbar);


if(expandToolbar){
                appBarLayout.setExpanded(true,true);
            }else{
                appBarLayout.setExpanded(false,true);
            }

Here is a usufal link disable expand on CollapsingToolbarLayout for certain fragments

对于某些片段,这是一个usufal链接禁用扩展CollapsingToolbarLayout

also for other people inteasing of changing some parts of their toolBar you should write your custom toolbar view in separate XML and try to inflate the custom view in your details Fragment grammatically then hide the unused elements of the old toolbar if there are any.

也可以为其他人改变工具的某些部分,你应该在单独的XML中编写自定义工具栏视图,并尝试在语法中夸大细节中的自定义视图,然后隐藏旧工具栏中未使用的元素(如果有的话)。

setSupportActionBar(toolbar);
View logo = getLayoutInflater().inflate(R.layout.view_logo, null);
toolbar.addView(logo);

and here is how u can hide unwanted Views

这就是你如何隐藏不需要的视图

for (int i = 0; i < toolbar.getChildCount(); ++i) {
        View child = toolbar.getChildAt(i);

        // here u can hide all text views for example.
        if (child instanceof TextView) {
            child.setVisibility(View.GONE );
        }
    }

this way is a lot better than writing two activities

这种方式比编写两个活动要好得多

更多相关文章

  1. 仪表测试自定义视图
  2. 无法将视图添加到相对布局
  3. ListView的上拉弹簧、下拉弹簧,下拉弹簧时动态带刷新和切换换刷新
  4. 在android上滚动时,列表视图的位置会发生变化
  5. 如何在android中的recycler视图中显示第一项的选择?
  6. springMVC使用html视图配置详解
  7. 自定义视图无法工作,直到我触摸屏幕
  8. 做一个没有视图的零食吧?

随机推荐

  1. 哪些年遇到过的Andriod问题(5)This text
  2. Android:在Eclipse下开发android应用产生
  3. android中国风笔记源码,金鱼游动动画源码
  4. (转帖)Android系列之浅谈Android 3D旋转
  5. android 图片的 放大 缩小 移动
  6. 使用Vitamio打造自己的Android万能播放器
  7. android Handler 机制研究学习笔记
  8. Android原生(Native)C开发之二 framebuff
  9. android BaseAdapter优化
  10. Android中图片占用内存的计算