android复杂首页布局

该博客主要介绍了如何实现Android应用的复杂首页布局,包括轮播图、公告、指示器和内容列表。轮播图采用BGABanner库,公告使用ViewFlipper,指示器借助MagicIndicator,内容列表使用ViewPager结合Fragment和RecyclerView。博客中还提到了其他依赖如anko、BaseRecyclerViewAdapterHelper、glide和gson,并提供了源码和目录结构的详细说明。
摘要由CSDN通过智能技术生成

示例图
原型图

分析:
通过分析原型图,分为4个模块

1.轮播图
2.公告
3.指示器
4.内容列表


实现:
轮播图使用BGABanner-Android
公告使用ViewFlipper控件
指示器切换使用MagicIndicator
内容列表使用ViewPager+Fragment(RecyclerView)

![实现图]
(https://coding.net/u/tea9/p/image/git/raw/master/blog_img/18/03.png)

其他依赖:

anko
BaseRecyclerViewAdapterHelper
glide
gson


源码:
homepage

目录结构:
activity
-HomeViewPagerActivity
adapter
-ViewPagerAdapter
fragment
-TabFragment


代码:

activity_home_viewpager.xml

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/cl_page">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:contentInsetLeft="0dp"
            app:contentInsetStart="0dp"
            app:layout_scrollFlags="scroll|enterAlways" >
            <include
                layout="@layout/item_banner" />

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

        <net.lucode.hackware.magicindicator.MagicIndicator
            android:id="@+id/magic_indicator"
            android:layout_width="match_parent"
            android:layout_height="40dp" />
    </android.support.design.widget.AppBarLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:scrollbars="none"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
        <android.support.v4.view.ViewPager
            android:id="@+id/view_pager"
            android:lay
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值