安卓NestedScrollView有应用程序后尺寸不合适:layout_behavior [英] Android NestedScrollView has wrong size after app:layout_behavior

查看:237
本文介绍了安卓NestedScrollView有应用程序后尺寸不合适:layout_behavior的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于谷歌已经发布了Android的设计支持库,还有可以在不实现自定义code做很多好东西。虽然我测试过这个lib中的自定义视图,我已经找到了更糟糕的事情,我不知道这是否是一个错误或没有。

Since Google has published the design support library for android, there are many nice things that can be done without implementing custom code. While i've tested the custom views in this lib, i have found a worse thing, and i didn't know if this is a bug or not.

我发现gi​​thub上cheesesquare项目。在 activity_detail.xml(版式文件)的存在是NestedScrollView内3 CardViews。如果您删除其中2,你可以看到,NestedScrollView没有父(match_parent)的全尺寸。该NestedScrollView绑定到父视图的底部。 http://i.stack.imgur.com/BXl7w.png

I have found the cheesesquare project on github. In the activity_detail.xml(layout file) there are 3 CardViews inside the NestedScrollView. If you delete 2 of them, you can see that the NestedScrollView doesn't have the full size of the parent(match_parent). The NestedScrollView is bound to the bottom of the parent view. http://i.stack.imgur.com/BXl7w.png

该NestedScrollView得到的他的全尺寸,当我删除应用程序:layout_behavior =@字符串/ appbar_scrolling_view_behavior

The NestedScrollView get's his full size when i remove the app:layout_behavior="@string/appbar_scrolling_view_behavior".

但是,当我删除的布局行为,工具栏不会崩溃。

But when i remove the layout behavior, the toolbar is not collapsing.

对此有任何解决?举例布局文件可以在这里找到:<一href="https://github.com/Smove/cheesesquare/blob/stackoverflow/app/src/main/res/layout/activity_detail.xml">https://github.com/Smove/cheesesquare/blob/stackoverflow/app/src/main/res/layout/activity_detail.xml

Is there any fix for this? Example layout file can be found here: https://github.com/Smove/cheesesquare/blob/stackoverflow/app/src/main/res/layout/activity_detail.xml

您可以从我的github分行建立cheesesquare APK 计算器

You can build the cheesesquare apk from my github branch stackoverflow

推荐答案

我有这个问题和固定加:

I had this problem and fixed adding:

android:layout_gravity="fill_vertical"

到NestedScrollView。然后,它开始表现正常,因为我解释这里也。当然,NestedScrollView需要一些样的孩子(即:不能为空),否则工具栏不会崩溃。

to the NestedScrollView. Then it starts behaving correctly, as I explained here also. Of course the NestedScrollView needs some kind of child (i.e. it must not be empty), otherwise the toolbar won't collapse.

在这个工程的以及的小内容,我发现它有一些问题,显示出更长的内容,例如:喜欢全 activity_detail.xml 上方。问题是,你不能滚动到内容的底部的一部分 - 这是不可达的底部

While this works well with small content, I noticed it has some problems showing longer contents, e.g. like the full activity_detail.xml above. The problem is that you can't scroll to the very bottom part of the content - it is unreachable at the bottom.

这是我的测试中,我可以发现,缺失的部分是作为大的折叠工具栏(或至少是它看起来对我来说)。要解决这个问题,有一个解决方案,可靠的小型和大的内容,你应该添加一个 layout_marginBottom 的滚动型,因此,它被测量和的发布的缺失的底部。因此:

From my tests I could find that the missing part is as big as the collapsed toolbar (or at least that's what it looks to me). To fix this is issue, and having a solution reliable for both small and big contents, you should add a layout_marginBottom to the ScrollView, so that it gets measured and releases the missing bottom part. Thus:

android:layout_gravity="fill_vertical"
android:layout_marginBottom="?attr/actionBarSize"

或任何大小,你给了工具栏

与该溶液小内容滚动,即使内容在顶部公正对齐,是不是真的光滑如具有大内容滚动。我将使用到的库修复来了。

Scrolling with small contents with this solution, even if the content is justly aligned at the top, isn't really smooth as scrolling with large contents. I'll use until a library fix comes.

看起来这是固定v22.2.1。

Looks like this was fixed in v22.2.1 .

这篇关于安卓NestedScrollView有应用程序后尺寸不合适:layout_behavior的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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