Android 奶酪广场:入口总是产生错误的布局
将Android 奶酪广场:入口总是产生错误的布局,android,material-design,android-support-library,android-design-library,android-collapsingtoolbarlayout,Android,Material Design,Android Support Library,Android Design Library,Android Collapsingtoolbarlayout,将enterally添加到Cheesesquare演示的滚动标志中: <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/collapsing_toolbar" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true
enterally
添加到Cheesesquare演示的滚动标志中:
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed|enterAlways">
向下滚动时,标题会正确进入,但不会停止在正确的位置。滚动会进一步替换部分:背景图像出现在错误的位置,并且由于背景颜色的变化,工具栏变得不可见。(我还在这里的工具栏中添加了一个colorPrimary
背景,以使其更加可见,但问题当然不取决于颜色)。这些库是今天最新的,23.1.0
是否有任何解决办法,或者我们必须等待它在图书馆修复?现在,它似乎是任何需要这一功能的应用程序的一个展示障碍
enterAlwaysCollapsed
可以工作,但它提供了不同的功能,这不是一个解决办法。我对AppBarLayout类源代码进行了一些修补,解决了这个问题。显然他们不认为人们会这样使用它。或者他们这么做了,我就走远了。不管怎么说,这对我很有效
你需要对这个方法做一点小小的改变。查找滚动\u标志\u退出\u,直到\u折叠
/**
* Return the scroll range when scrolling down from a nested pre-scroll.
*/
private int getDownNestedPreScrollRange() {
if (mDownPreScrollRange != INVALID_SCROLL_RANGE) {
// If we already have a valid value, return it
return mDownPreScrollRange;
}
int range = 0;
for (int i = getChildCount() - 1; i >= 0; i--) {
final View child = getChildAt(i);
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
final int childHeight = child.getMeasuredHeight();
final int flags = lp.mScrollFlags;
if ((flags & LayoutParams.FLAG_QUICK_RETURN) == LayoutParams.FLAG_QUICK_RETURN) {
// First take the margin into account
range += lp.topMargin + lp.bottomMargin;
// The view has the quick return flag combination...
if ((flags & LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED) != 0) {
// If they're set to enter collapsed, use the minimum height
range += ViewCompat.getMinimumHeight(child);
// This is what is missing...
} else if ((flags & LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED) == LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED) {
range += childHeight - ViewCompat.getMinimumHeight(child);
} else {
// Else use the full height
range += childHeight;
}
} else if (range > 0) {
// If we've hit an non-quick return scrollable view, and we've already hit a
// quick return view, return now
break;
}
}
return mDownPreScrollRange = range;
}
如果正在使用,则可能需要减小状态栏的高度
“android:fitsystemwindows=“true”
希望有帮助。您需要从设计库中复制一些类以允许所有导入&一些方法将公开
干杯。聪明。它可能可以工作,但我还没有设法使所有依赖文件都工作。:-)但是你能将它发布到Android问题队列中吗?Chris Banes可能会欢迎它,并将其包括在下一个版本中…必须修复AppBarLayout代码和崩溃的ToolBarLayout,以使其正常工作,因为它依赖于类cies。对于这样一个问题,有太多的工作要做。希望他们能尽快解决。我不确定他们会不会解决,除非你发出问题的信号并在那里提供解决方案。:-)请原谅我的无知,但我该怎么做?事实上,我自己从来没有这样做过,但很多时候你会被发送到问题队列中,像这样:。所以,看起来你只是提交了一个新问题(不需要单独注册,它属于谷歌所有权利)