一个大型新闻app的骨架(android)

前端做着太枯燥了,最近使劲折腾android,又因为曾经待过一家公司是做新闻app的,所以对新闻类app特别执着。折腾reactnative,flutter,android时,UI都是模仿这种新闻类。

先来看一下效果

android.gif

看这效果,顺便参考了掘金的结构。

来看一下实现思路

先做沉侵式处理

 true

底部导航是用官方的组件BottomNavigationView

 

这个比较简单,构建项目的时候,选择BottomNavigationView就行了,简单的操作。。。

BottomNavigationView的第一个fragment,有一个顶部tab导航栏,实现方案为TabLayout+ViewPager+Fragment




    

这里会出现fragment嵌套fragment,为了避免出现滑动冲突,重写ViewPager

public class NoScrollViewPager extends ViewPager {
    public NoScrollViewPager(Context context) {
        super(context);
    }
    public NoScrollViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        return false;
    }
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return false;
    }

}

然后layout中


因为是自定义顶部导航栏,所以把ActionBar隐藏,并且自定义导航栏时注意下高度和padding-top

getSupportActionBar().hide();//隐藏掉整个ActionBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:scrollbars="none"

activity的跳转就简单了,就是一个简单的intent

 Intent intent =new Intent(getActivity(),Main3Activity.class);
                startActivity(intent);

另一个新的activty用的是官方的侧滑DrawerLayout控件,在项目内新建一个DrawerLayout的activty就行了。



    
    

    


=============

还有一些简单的操作,比如webview... ... 大家可前往github查看
源码

你可能感兴趣的:(一个大型新闻app的骨架(android))