Android 状态栏的沉浸式轮播图

效果如下

轮播图的开源项目地址

https://github.com/youth5201314/banner/blob/master/README.md

具体布局为

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

            <android.support.design.widget.AppBarLayout
                android:layout_width="match_parent"
                android:layout_height="250dp">
                <android.support.design.widget.CollapsingToolbarLayout
                    android:id="@+id/collapsing_toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
                    app:contentScrim="?attr/colorPrimary"
                    app:layout_scrollFlags="scroll|exitUntilCollapsed">
                    <!--轮播图片-->
                    <com.youth.banner.Banner
                        android:id="@+id/banner"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" />

                    <android.support.v7.widget.Toolbar
                        android:id="@+id/grad_toolbar"
                        android:layout_width="match_parent"
                        android:fitsSystemWindows="true"
                        android:layout_height="?attr/actionBarSize"
                        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="wrap_content"
                   android:orientation="vertical"
                   android:weightSum="1">
                   <android.support.v7.widget.CardView
                       android:layout_height="wrap_content"
                       android:layout_width="match_parent"
                       android:layout_marginBottom="15dp"
                       android:layout_marginLeft="15dp"
                       android:layout_marginRight="15dp"
                       android:layout_marginTop="20dp"
                       app:cardCornerRadius="4dp">
                       <TextView
                           android:layout_width="wrap_content"
                           android:layout_height="wrap_content"
                           android:layout_margin="10dp"
                           android:id="@+id/userText"
                           android:text="dadasdasdasdasdsdasdadsdasdasddasdasasd
         adsdasdasdasasdasdasdasddsadaddadasdasdasddsdads
         sdsdasdasdasdadsdasdasdasdasdasdasdasdasdasdasdasdsdasdsdadsd"
                           android:textAppearance="@style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Small" />
                   </android.support.v7.widget.CardView>

                   <TextView
                       android:layout_width="wrap_content"
                       android:layout_height="wrap_content"
                       android:layout_marginTop="5dp"
                       android:layout_marginLeft="25dp"
                       android:id="@+id/grade_Text"
                       android:text="评分"
                       android:textAppearance="@style/TextAppearance.AppCompat.SearchResult.Title" />

                   <RatingBar
                          android:id="@+id/rbRating"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center"
                          android:layout_marginTop="10dp"
                          />
                           <TextView
                               android:layout_width="wrap_content"
                               android:layout_height="wrap_content"
                               android:layout_marginTop="5dp"
                               android:layout_marginLeft="25dp"
                               android:id="@+id/grade_Text1"
                               android:text="评分为"
                               android:textAppearance="@style/TextAppearance.AppCompat.Display1" />


                   <Button
                       android:id="@+id/submission"
                       android:layout_width="match_parent"
                       android:layout_height="wrap_content"
                       android:layout_marginTop="30dp"
                       android:background="@drawable/shape"
                       android:text="提  交"
                       android:textColor="#ffffff"
                       android:textSize="18dp"
                       android:layout_marginRight="15dp"
                       android:layout_marginLeft="15dp"

/>


               </LinearLayout>
           </android.support.v4.widget.NestedScrollView>



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

活动里面的图片设置,轮播图的更多详细用法请移步上面的开源项目

      Banner banner = (Banner) findViewById(R.id.banner);
        List images=new ArrayList<>();
        images.add(R.drawable.user1);
        images.add(R.drawable.user);
        banner.setImages(images).setImageLoader(new GlideImageLoader()).start();

public class GlideImageLoader extends ImageLoader {
    @Override
    public void displayImage(Context context, Object path, ImageView imageView) {
        Glide.with(context).load(path).into(imageView);
    }


}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值