从零开始打造一个新闻订阅APP之Android篇(一、实现仿微信主界面效果)

微信作为面向大众的产品,它的界面一直保持简洁的风格,实现布板的主界面时也参考了很多APP的设计,最终决定采用类似于微信的主界面,即四个tab滑动。
google了一把之后,找到了一款滑动利器PagerSlidingTabStrip。
官网地址:https://github.com/astuetz/PagerSlidingTabStrip
官方效果图如下:
这里写图片描述
但使用过程中发现想要把滑动tab放到底部更改布局相当麻烦,后来自己思考并结合了guolin大神的一篇介绍Fragment的文章 Android Fragment应用实战,使用碎片向ActivityGroup说再见,终于完美地实现了想要的效果,如下是最终的效果图:
这里写图片描述
首先新建一个activity_main.xml布局文件,代码如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools= "http://schemas.android.com/tools"
    xmlns:pagerslidingtabstrip="http://schemas.android.com/apk/res-auto"
    android:layout_width= "match_parent"
    android:layout_height= "match_parent"
    android:background= "@color/mainbackground"
    android:clipChildren= "false"
    android:clipToPadding= "false"
    >
     <com.astuetz.PagerSlidingTabStrip
        android:id= "@+id/mainTabs"
        android:layout_width="match_parent"
        android:layout_height="10dp"
        android:visibility="gone"
        />
     <android.support.v4.view.ViewPager
        android:id= "@+id/mainPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />

     <LinearLayout
         android:layout_alignParentBottom="true"
         android:layout_width="match_parent"
        android:layout_height="50dp"
         android:clipChildren="false"
     android:clipToPadding= "false"
     android:background= "@color/mainbackground"
     android:baselineAligned= "false"
         >
            <LinearLayout
               android:id= "@+id/onlyYou"
               android:layout_width="0dp"
               android:layout_weight="1"
               android:layout_height="match_parent"
               android:gravity="center"
               android:orientation="vertical"
               >
               <ImageView
                 android:id= "@+id/onlyYouImage"
                 android:layout_width="25dp"
                 android:layout_height="25dp"
                 />
             <TextView
                 android:id= "@+id/onlyYouText"
                 android:textSize="10sp"
                 android:text="@string/onlyyou"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                />
            </LinearLayout>
            <LinearLayout
               android:id= "@+id/guang"
               android:layout_width=
  • 1
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值