首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >具有带图片的循环视图的折叠工具栏

具有带图片的循环视图的折叠工具栏
EN

Stack Overflow用户
提问于 2017-11-04 16:48:08
回答 2查看 370关注 0票数 0

如果这个问题是重复的,我很抱歉。我是android编程的新手,我正在为公共交通构建应用程序,到目前为止我已经做到了这一点:从google获取方向,解析json数据,并在地图上显示。现在我想在列表视图中显示带有公共汽车和火车图标的路线。

我已经看到,这可以通过折叠工具栏和循环视图来完成,但我看到的每个教程都会出错,因为这是Android studio 3.0。

这是我想展示的图片

在这个列表视图中,我想添加图片,如如果是有轨电车运输比有轨电车图标的公交车,如果它是多个有轨电车或公交线路的组合来显示。有人能帮助我或给我建议吗?

EN

回答 2

Stack Overflow用户

发布于 2017-11-04 16:58:12

Android提供了CollapsingToolbarLayout,当滚动它时,它会在循环视图中折叠工具栏。使用以下命令:

代码语言:javascript
复制
android.support.design.widget.CollapsingToolbarLayout

有关更多信息,请阅读CollapsingToolbarLayout

编码快乐!!

票数 0
EN

Stack Overflow用户

发布于 2017-11-04 17:14:26

试试这段代码。这对我来说很有效,只需简单地将imageview放在拼版布局中,并根据您的选择进行更改。

代码语言:javascript
复制
  <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="vertical"
    android:animateLayoutChanges="true"
    tools:context="com.example.intel.magitor.My_Creation_Activity"
    >




    <android.support.design.widget.AppBarLayout
        android:background="#fff"
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="400dp"
        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:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="scroll|snap|exitUntilCollapsed">
            <!--<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" />-->
<!-- use this v7.wdiget.toolbar if you want to display title collpasing layout-->
<!-- put here your image you want to collpase while scrolling-->

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





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


    <android.support.v7.widget.RecyclerView
        android:id="@+id/video_list"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"



        >

    </android.support.v7.widget.RecyclerView>



</android.support.design.widget.CoordinatorLayout>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47109025

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档