1
A
回答
0
你需要touse CoordinatorLayout爲你的父母的ViewGroup和錨您的詳細視圖到您的工具欄,在我的情況下它是CollapsingToolbarLayout。
這裏是我的xml文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/annonce.main.coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="RtlHardcoded"
android:text="hello"
>
<android.support.design.widget.AppBarLayout
android:id="@+id/flexible.example.appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="hello"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/flexible.example.collapsing"
android:layout_width="match_parent"
android:layout_height="300dp"
app:expandedTitleMarginBottom="94dp"
android:text="hello"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:expandedTitleTextAppearance="@android:style/TextAppearance.Inverse"
app:contentScrim="?colorPrimary">
<ImageView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:src="@mipmap/ic_launcher"
android:tint="#BB3E50B4"
android:scaleType="centerCrop"
/>
<android.support.v7.widget.Toolbar
android:id="@+id/flexible.example.toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@null"
android:title="hello"
app:layout_collapseMode="pin"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="300dp"
android:layout_height="250dp"
android:background="@android:color/holo_green_light"
app:layout_anchor="@id/flexible.example.collapsing"
app:layout_anchorGravity="bottom|center_horizontal"
tools:ignore="RtlHardcoded"
></LinearLayout>
</android.support.design.widget.CoordinatorLayout>
這是我的佈局的預覽:
http://oi64.tinypic.com/15dwfv4.jpg
最有趣的部分是在LinearLayout
:
app:layout_anchor="@id/flexible.example.collapsing"
app:layout_anchorGravity="bottom|center_horizontal"
描述你的細節佈局應該是pi NNED。
希望這將有助於
相關問題
- 1. 如何禁用Coordinatorlayout文本?
- 2. ToolbarAlphaScrollBehavior CoordinatorLayout
- 3. 如何崩潰的ImageView嵌套在CoordinatorLayout
- 4. CoordinatorLayout with ViewPager
- 5. 奇怪的CoordinatorLayout
- 6. CollapsingToolbarLayout + Coordinatorlayout + ViewPager + Fragment
- 7. CoordinatorLayout與RecyclerView:onScroll
- 8. BottomSheetBehavior不CoordinatorLayout
- 9. setfitsystemwindows not working windowtranslucentstatus coordinatorlayout
- 10. Android CoordinatorLayout顯示ActionBar
- 11. CoordinatorLayout中的NullPointerException onTouchEvent
- 12. Android的CoordinatorLayout在Xamarin.Forms
- 13. CoordinatorLayout類未找到
- 14. 使用CoordinatorLayout和ListView
- 15. RecyclerView內NestedScrollView內CoordinatorLayout
- 16. 無法解析符號CoordinatorLayout
- 17. LinearLayout無法鑄造到CoordinatorLayout
- 18. CoordinatorLayout與RecyclerView和摺疊頭
- 19. 抽屜CoordinatorLayout和工具欄
- 20. CoordinatorLayout底部的工具欄
- 21. 將imageView添加到coordinatorLayout
- 22. CoordinatorLayout - match_parent不起作用
- 23. CoordinatorLayout不隱藏操作欄
- 24. CoordinatorLayout layout_anchor滾動時跳轉?
- 25. CoordinatorLayout中的水平RecyclerView?
- 26. 帶有CoordinatorLayout和AppBarLayout的Recyclerview
- 27. android studio CoordinatorLayout&RecyclerView空白?
- 28. CoordinatorLayout不顯示ViewStub子代
- 29. 將Footer添加到CoordinatorLayout
- 30. 奇怪的CoordinatorLayout/AppBarLayout行爲
謝謝你,但我用nestedScrollview我的觀點,但顯示錯誤,如果添加線條應用:layout_anchor = 「@ ID/collapsing_toolbar」,應用程序:layout_anchorGravity = 「底部| CENTER_HORIZONTAL」,應用程序:layout_behavior =「@ string/appbar_scrolling_view_behavior」,消息是java.lang.ClassCastException:android.support.design.widget.AppBarLayout $ LayoutParams不能轉換爲android.support.design.widget.CoordinatorLayout $ LayoutParams –