| 一、问题描述 |
本系列将结合案例应用,陆续向大家介绍一些Android典型界面的设计,首先说说tab导航,导航分为一层和两层(底部区块+区域内头部导航),主要实现方案有RadioGroup+ViewPage+Fragment、Viewpager Indicator、ActionBar Tabs、FragmentTabHost+Fragment等,下面我们先采用RadioGroup+ViewPage+Fragment实现区域头部导航。
如图所示:

| 二、案例主要组件 |
1、先看一下MainActivity布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <HorizontalScrollView android:id="@+id/hvChannel" android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="none" > <RadioGroup android:id="@+id/rgChannel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> </RadioGroup> </HorizontalScrollView> <android.support.v4.view.ViewPager android:id="@+id/vpNewsList" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" > &

这篇博客介绍了如何在Android中实现区域顶部tab滑动切换,采用RadioGroup+ViewPager+Fragment的方式。内容包括MainActivity的布局和代码,动态添加RadioButton,导航按钮的数据来源,外观设计,以及PageFragmentAdapter适配器和NewsFragment组件的使用。读者可以通过查看源码和加入官方QQ群进行深入学习和技术交流。
最低0.47元/天 解锁文章
1428

被折叠的 条评论
为什么被折叠?



