我一直在尝试使用新的similar to this从材料设计指南中实现布局Android Design Support Library。 CollapsingToolbarLayout
似乎是要走的路,但它忽略了任何添加高程的尝试。此外,如果我将AppBarLayout
的高度设置为大约144dp以下的任何值,FloatingActionButton
将弹出,但不会返回。这是我的xml:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="144dp"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:expandedTitleMarginEnd="72dp"
app:expandedTitleMarginStart="72dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:paddingLeft="72dp"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_person_add_white_24dp"
app:borderWidth="0dp"
app:fabSize="mini"
app:layout_anchor="@id/appbar"
app:layout_anchorGravity="bottom|left|start"/>
答案 0 :(得分:3)
在深入了解源代码后,我发现FloatingActionButton
附加到AppBarLayout
时,只有在可用空间为<=appBarLayout.getMinimumHeightForVisibleOverlappingContent()
时才会显示Toolbar
,最小为2 *高度(在这种情况下为getMinimumHeightForVisibleOverlappingContent()
),加上状态栏。所以在手机上的肖像,56 * 2 + 26 = 138dp。我通过将我的设置为138dp确认了这一点,这有效,而137dp没有。如果您想解决此问题,可以覆盖AppBarLayout
中的FloatingActionButton
或public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton child, View dependency) {
if(dependency instanceof SnackbarLayout) {
this.updateFabTranslationForSnackbar(parent, child, dependency);
} else if(dependency instanceof AppBarLayout) {
AppBarLayout appBarLayout = (AppBarLayout)dependency;
if(this.mTmpRect == null) {
this.mTmpRect = new Rect();
}
Rect rect = this.mTmpRect;
ViewGroupUtils.getDescendantRect(parent, dependency, rect);
if(rect.bottom <= appBarLayout.getMinimumHeightForVisibleOverlappingContent()) {
if(!this.mIsAnimatingOut && child.getVisibility() == 0) {
this.animateOut(child);
}
} else if(child.getVisibility() != 0) {
this.animateIn(child);
}
}
return false;
}
中的以下方法:
CollapsingToolbarLayout
关于Option Explicit
Sub Workbook_Open()
' This routine is called when the workbook is opened.
With Worksheets("Sheet1")
Dim ordercount As Integer
ordercount = ActiveWorkbook.Worksheets("Sheet1").Range("A2", Worksheets("Sheet1").Range("A2").End(xlDown)).Rows.Count
'create matchcount column
Range("G1").Select
ActiveCell.FormulaR1C1 = "Match Count"
Columns("G:G").Select
'create batchsheet
Sheets.Add After:=Sheets(Sheets.Count)
Sheets("Sheet4").Select
Sheets("Sheet4").Name = "batches"
Sheets("Sheet1").Select
Range("A1:G1").Select 'copying the headers into new sheet
Selection.Copy
Sheets("batches").Select
Range("A1").Select
ActiveSheet.Paste
End With
End Sub
Sub match()
Do Until ordercount = 0
Dim currentrow As Long
currentrow = 2
Dim matchrange As Range
Set matchrange = Worksheets("sheet1").Columns("B3:F")
Location = Range("B2:F").Cells.Value
For Each Row In matchrange
Dim matchcount As Integer
matchcount = 0
For Each cell In Row
If currentrow.Location = Location And Location > 0 Then 'I don't want the 0's to count as matches
matchcount = matchcount + 1
Next
Column("G").Row.cell.Value = matchcount
Next
Call sort
Call Remove
Loop
End Sub
Sub sort()
Columns("G:G").Select
ActiveWorkbook.Worksheets("Sheet1").sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").sort.SortFields.Add Key:=Range("G1"), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").sort
.SetRange Range("G3:G")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Sub Remove()
Range("A2:G11").Select
Selection.Cut
Sheets("Sheet2").Select
Range("A2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Selection.Delete Shift:=xlUp
End Sub
提升,我还没有找到解决方法。
答案 1 :(得分:2)
对于CollapsingToolbarLayout
提升,您可以在子类CollapsingToolbarLayout.OffsetUpdateListener
中搜索方法onOffsetChanged
来完成工作
if(Math.abs(verticalOffset) == scrollRange) {
ViewCompat.setElevation(layout, layout.getTargetElevation());
} else {
ViewCompat.setElevation(layout, 0.0F);
}
答案 2 :(得分:2)
关于高程,折叠工具栏布局在未折叠时显式删除高程*。它已被提交为一个错误似乎:
(正如@Ben在他的回答和对源代码的引用中所说的那样)
直接链接到代码(目前,第1062行): https://android.googlesource.com/platform/frameworks/support/+/master/design/src/android/support/design/widget/CollapsingToolbarLayout.java#1062
if (Math.abs(verticalOffset) == scrollRange) {
// If we have some pinned children, and we're offset to only show those views,
// we want to be elevate
ViewCompat.setElevation(layout, layout.getTargetElevation());
} else {
// Otherwise, we're inline with the content
ViewCompat.setElevation(layout, 0f);
}