不能容纳appbar和活性在同一画面 [英] Can't fit appbar and the activity in the same screen

查看:323
本文介绍了不能容纳appbar和活性在同一画面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个Android应用程序,并使用了Android材料设计应用程序栏IM。我想,以适应活动在屏幕的appbar,我不能做到这一点。

I'm building a android app and im using the android material design app bar. I wanted to fit the activity in the screen with the appbar and I cant do it.

我有这行code的:

  app:layout_behavior="@string/appbar_scrolling_view_behavior"

这行让我适应屏幕上的活动,但有些内容是在屏幕下方。无论appbar和内容是不同的XML文件(不知道他们是否认为是片段)。谁能帮以适应屏幕内容而无需正对appbar的顶部?

This line allow me to fit the activity in the screen but some content is below the screen. Both appbar and the content are different xml files (don't know if they are consider as fragments). Can someone help to fit the content in the screen without being on top of the appbar?

如果我用这个行:

在这里输入的形象描述

和没有它:

在这里输入的形象描述

推荐答案

有对你的问题的解决方案。
案例1:如果您不希望滚动或崩溃的标签和工具栏(即您的内容不滚动能):

There is solutions to your problem. case 1: if you does not want to scroll or collapse tabs and toolbar(i.e. your content is not scroll-able):

您不应该使用应用:中layout_behavior =@字符串/ appbar_scrolling_view_behavior,而是将 layout_marginTop 以内容的根视图向上到(工具栏+选项卡)的高度。如果您使用的是标准高度那就 48 + 48 = 96dp (你应该检查并确认这些尺寸)。

You should not use app:layout_behavior="@string/appbar_scrolling_view_behavior", instead of it set layout_marginTop to root view of content up-to height of(toolbar+tabs). If you are using standard heights then it is 48+48 = 96dp (you should check and verify these dimensions).

案例2:
如果你有能滚动的内容或希望能够滚动的内容,然后只使用NestedScrollView作为内容的ViewGroup根和停止担心的行为。它将工作正确的自动运行。

case 2: If you have scroll able content or want to scroll able content, then just use NestedScrollView as a root viewGroup of content and stop worrying about behavior. It will work correct automatically.

这篇关于不能容纳appbar和活性在同一画面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆