视差滚动想实现一个片段内的视差滚动效果,活动包含视图寻呼机,寻呼机查看项目的片段,我如何实现它里面的视差滚动效果。片段布局有两个孩子。一个Image和TextView在它下面。 ImageView应该具有视差效果。我如何实现在片段的Android
0
A
回答
0
使用下面的代码作为例子仔细看,你应该能够达到你所需要的,只是复制粘贴您的片段布局文件中下面的代码,看看它是如何看起来这样做之前,所以备份你的布局的情况下,去背部。
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/detail_backdrop_height"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="24dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/card_margin">
<LinearLayout
style="@style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Info"
android:textAppearance="@style/TextAppearance.AppCompat.Title" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/cheese_ipsum" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/card_margin"
android:layout_marginLeft="@dimen/card_margin"
android:layout_marginRight="@dimen/card_margin">
<LinearLayout
style="@style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Friends"
android:textAppearance="@style/TextAppearance.AppCompat.Title" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/cheese_ipsum" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/card_margin"
android:layout_marginLeft="@dimen/card_margin"
android:layout_marginRight="@dimen/card_margin">
<LinearLayout
style="@style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Related"
android:textAppearance="@style/TextAppearance.AppCompat.Title" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/cheese_ipsum" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:layout_anchor="@id/appbar"
app:layout_anchorGravity="bottom|right|end"
android:src="@drawable/ic_discuss"
android:layout_margin="@dimen/fab_margin"
android:clickable="true"/>
+0
感谢您的回答您的布局文件。它工作正常:)。还有一个问题是,我们可以有工具栏活动布局,实现同样的效果。 –
+0
它会加倍只是让独立的工具栏XML布局,包括它无论你想 – Haroon
1
相关问题
- 1. 在Android片段上实现搜索
- 2. 如何在Android Studio的片段中实现自定义字体
- 3. 如何在片段中实现onTouchEvent()?
- 4. 如何在片段中实现onClick?
- 5. 如何在RecyclerView片段中实现onActivityResult
- 6. Android中实现侦听器的片段
- 7. 我怎样才能在片段实现我的接口在另一个片段
- 8. 如何实现从片段A到片段B的监听器?
- 9. 在片段中实现RecyclerView
- 10. 片段实现OnClickListener
- 11. 如何实现内部片段
- 12. 如何通过片段实现全屏?
- 13. 如何实现意图从另一个片段调用片段
- 14. 如何从片段视图中实现Android微调器
- 15. 如何实现退出双重背部按下片段[Android]
- 16. 如何跨不同片段重用Android片段实例?
- 17. 片段实例或多个片段(Android)
- 18. 如何实现在android中包含2个片段的活动左右滑动?
- 19. 如何在Android中的相同片段中实现关系视图?
- 20. 我如何在android中实现SlideShow?
- 21. 在CustomListAdapter中传递实例时出现问题的Android片段
- 22. 如何在magento产品中实现丰富的代码片段?
- 23. 我如何在我的Java框架中实现一张图片
- 24. Android:我如何在片段中更新我的textView
- 25. Android获取片段的实际实例
- 26. 在我的活动通话tablayout如何实现片段和AppCompatActivity在一个活动中的Android
- 27. 调用片段在drawermenu中实现View.OnClickListener
- 28. 在片段中实现滑动标签
- 29. Android实现上的实时照片?
- 30. RecyclerView没有出现在我的片段
向我们展示你已经尝试了什么。 – TdSoft