gpt4 book ai didi

android - CollapsingToolbarLayout/工具栏边距错误

转载 作者:搜寻专家 更新时间:2023-11-01 07:53:54 25 4
gpt4 key购买 nike

我想在我的应用程序中使用类似于@chrisbanses cheesesquare ( https://github.com/chrisbanes/cheesesquare ) 的布局。

在 Nexus 5,6 上一切正常。但是当您在三星 S6、索尼 Z3 Compact 等其他设备上测试时,工具栏中的按钮不可见。

enter image description here

<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/detail_backdrop_height"
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"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">

<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="@drawable/default_vehicle"
app:layout_collapseMode="parallax" />

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

</android.support.design.widget.CollapsingToolbarLayout>

这是我的布局。我找不到解决这个问题的方法。您可以尝试在 Samsung S 等手机上运行 Cheesesquare 5.0.2 Android。我还测试了索尼设备。相同。 Nexus 手机没问题。

你知道如何解决这个问题吗?

我正在使用 com.android.support:design:22.2.0(最新版本)

最佳答案

好的。我得到了确认。这是设计支持库 22.2.0 中的错误。更多信息: https://code.google.com/p/android/issues/detail?id=176647

如果您在 Google 发布修复程序之前知道任何解决方法,我将不胜感激。

工具栏和丢失按钮问题(错误位置)有一个解决方法

if (Build.VERSION.SDK_INT != 21) return; 

final int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
final int result = (resourceId > 0) ? getResources().getDimensionPixelSize(resourceId) * 2 : 0;
final CollapsingToolbarLayout.LayoutParams params =
(CollapsingToolbarLayout.LayoutParams) toolbar.getLayoutParams();
params.topMargin -= result;
toolbar.setLayoutParams(params);

编辑:Google 更新了支持库。此错误已在 22.2.1 版本中修复。只需更新支持库并使用最新版本,一切都会好起来的。

关于android - CollapsingToolbarLayout/工具栏边距错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30867429/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com