今天,翻看学习公司代码,公司界面布局类似今日头条布局,特别是顶部头布局,我对搭建很感兴趣,特在此留下,以供学习参考:
<?xml version="1.0" encoding="utf-8"?> <FrameLayout 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:background="@drawable/body_bg" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="40dp" android:background="@color/red_normal" android:gravity="center_vertical" android:orientation="horizontal"> <android.support.v7.widget.RecyclerView android:id="@+id/nav_1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center_vertical" /> <ImageView android:id="@id/search" android:layout_width="wrap_content" android:layout_height="50dp" android:layout_alignParentRight="true" android:paddingLeft="@dimen/marginTop10" android:paddingRight="@dimen/marginTop10" android:src="@drawable/ic_glass_small" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="40dp" android:background="@color/transparent" android:gravity="center_vertical" android:orientation="horizontal"> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"> <android.support.v7.widget.RecyclerView android:id="@+id/nav_2" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical" /> <ImageView android:layout_width="50dp" android:layout_height="match_parent" android:layout_gravity="right" android:background="@drawable/gradient" /> </FrameLayout> <ImageView android:id="@id/add" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:paddingLeft="15dp" android:paddingRight="15dp" android:src="@drawable/ic_add_black" /> </LinearLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v4.view.ViewPager android:id="@+id/viewPager1" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone" /> <android.support.v4.view.ViewPager android:id="@+id/viewPager2" android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout> </LinearLayout> <include layout="@layout/net_error_layout" android:visibility="gone"/> </FrameLayout>布局参考图片如下: