Leo*_*rdo 0 android android-layout android-glide
使用CollapsingToolbarLayout,Toolbar和嵌入的ImageView时,我遇到了一个奇怪的行为.这是我的代码:
<android.support.design.widget.AppBarLayout
android:id="@+id/bla"
android:layout_width="match_parent"
android:layout_height="256dp">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
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="@color/md_white_1000"
android:minHeight="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"
app:theme="@style/ThemeOverlay.AppCompat.Light" />
<ImageView
android:id="@+id/fragment_kids_profile_pic"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
Run Code Online (Sandbox Code Playgroud)
和Glide建设者:
Glide.with(getActivity())
.load(file)
.fitCenter()
.into(profilePicture);
Run Code Online (Sandbox Code Playgroud)
在通过Glide设置图像之前,工具栏行为完全正常,在我的情况下是"固定".设置图像后,工具栏布局丢失,图像发生(向上滚动后).一些照片要澄清:
任何帮助,将不胜感激 !
这是因为CollapsingToolbarLayout延伸FrameLayout.在FrameLayout视图层次结构的最后一个视图中是顶部的那个(如果你没有在代码中更改它),所以你ImageView覆盖了它是正常的Toolbar.要解决这个"问题",您只需更改顺序:
<android.support.design.widget.AppBarLayout
android:id="@+id/bla"
android:layout_height="256dp"
android:layout_width="match_parent">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/fragment_kids_profile_pic"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:scaleType="centerCrop" />
<android.support.v7.widget.Toolbar
android:background="@color/md_white_1000"
android:id="@+id/toolbar"
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"
app:theme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
Run Code Online (Sandbox Code Playgroud)
在您设定的图像通过Glide的ImageView的背景是透明的,这就是为什么你可以看到Toolbar.
| 归档时间: |
|
| 查看次数: |
927 次 |
| 最近记录: |