我正在使用CollapsingToolbarLayout,当collapsingToolbarLayout提起时,我想在工具栏上显示配置文件图像以及标题。请提供相关的代码或库。CollapsingToolbarLayout与工具栏上的图像android
回答
使用这样的:
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="200dp"
android:fitsSystemWindows="false"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleTextAppearance="@style/TransparentText"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:foreground="?attr/selectableItemBackground"
android:orientation="vertical"
android:paddingTop="?actionBarSize"
app:layout_collapseMode="parallax">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/test_img"
android:id="@+id/profile_image">
</ImageView>
</FrameLayout>
<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/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
用它在你的coordinateLayout。并根据您的喜好定位您的图片。
我试过这个,但它不工作,因为我喜欢。请参考这个更好的理解http://stackoverflow.com/questions/33066164/add-a-imageicon-to-the-collapsing-layout-support-library –
参考这个链接:[链接] http://saulmm.github .io/mastering-coordinator 这是很好的文章坐标布局 –
我需要在折叠后显示在工具栏上的图像 –
- 1. CollapsingToolBarLayout,工具栏和菜单
- 2. CollapsingToolBarLayout有双重工具栏
- 3. 在CollapsingToolbarLayout图表在工具栏后面
- 4. CollapsingToolbarLayout中心工具栏中的TextView
- 5. CollapsingToolbarLayout并滚动时隐藏工具栏
- 6. CollapsingToolbarLayout /工具栏保证金缺陷
- 7. 工具栏不能位于CollapsingToolbarLayout顶部
- 8. 使工具栏在CollapsingToolbarLayout中消失
- 9. CollapsingToolbarLayout标题不放入工具栏
- 10. CollapsingToolbarLayout /工具栏过早/过时淡化
- 11. CollapsingToolbarLayout问题:与工具栏重叠的UI
- 12. 底部工具栏与3图像
- 13. 双工具栏上的Android
- 14. 如何在android的collapsingtoolbarlayout工具栏下面粘贴视图元素?
- 15. CollapsingToolbarLayout图像低于状态栏
- 16. 如何向右对齐Android中工具栏上的图像
- 17. 工具栏图像错误
- 18. 与Android工作室的工具栏中的列表视图
- 19. 第二个工具栏就像在邮件+工具栏上NSScrollView
- 20. inflateMenu不工作在工具栏里面CollapsingToolbarLayout
- 21. 搜索栏与工具提示的Android
- 22. 的Android DrawerLayout与自定义工具栏
- 23. CollapsingToolbarLayout图像缩放
- 24. 带图像的自定义工具栏
- 25. 更改工具栏按钮的图像
- 26. 在工具栏上覆盖图像视图的一部分
- 27. 如何将文本放在CollapsingToolbarLayout和工具栏的中心?
- 28. CollapsingToolbarLayout + TabLayout,奇怪的工具栏标题边距
- 29. Android Studio上的工具栏呈现
- 30. 把工具栏上面的ActionBar android
你使用的是android studio还是eclipse? – AbhayBohra
我正在使用android工作室 –