OSChina App代码分析二

来源:互联网 发布:百度的端口号 编辑:程序博客网 时间:2024/05/08 01:23

转载请标明出处:
http://blog.csdn.net/zq2114522/article/details/50346073;
本文出自:【梁大盛的博客】

在第二篇里面我们首先分析OSChinaApp的主布局文件activity_main.xml.

主布局采用DrawerLayout来实现.
主布局据就一个FrameLayou和一个FragmentTabHost.侧拉栏是用一个Fragment填充.快捷按钮是一个ImageView覆盖在FragmentTabHost之上.

布局很简单也很清晰,没什么特别多需要讲解的.但是想写一些布局所引出来的东西.具体看后面的附上的链接.

<android.support.v4.widget.DrawerLayout     xmlns:tools="http://schemas.android.com/tools"    xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/drawer_layout"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context="net.oschina.app.ui.MainActivity" >    <LinearLayout        android:layout_width="match_parent"        android:layout_height="match_parent"        android:orientation="vertical" >        <FrameLayout            android:id="@+id/realtabcontent"            android:layout_width="match_parent"            android:layout_height="0dip"            android:layout_weight="1" />        <FrameLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:background="?attr/windows_bg" >            <RelativeLayout                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:layout_marginBottom="4dip" >                <net.oschina.app.widget.MyFragmentTabHost                    android:id="@android:id/tabhost"                    android:layout_width="match_parent"                    android:layout_height="wrap_content"                    android:layout_marginTop="4dip" />                <View                    android:layout_width="match_parent"                    android:layout_height="10px"                    android:background="?attr/lineColor" />            </RelativeLayout>            <!-- 快速操作按钮 -->            <ImageView                android:id="@+id/quick_option_iv"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:layout_gravity="center"                android:contentDescription="@null"                android:src="@drawable/btn_quickoption_selector" />        </FrameLayout>    </LinearLayout>    <!-- 左侧侧滑菜单 -->    <fragment        android:id="@+id/navigation_drawer"        android:name="net.oschina.app.ui.NavigationDrawerFragment"        android:layout_width="@dimen/navigation_drawer_width"        android:layout_height="match_parent"        android:layout_gravity="start"        tools:layout="@layout/fragment_navigation_drawer" /></android.support.v4.widget.DrawerLayout>
0 1
原创粉丝点击