现在的APP主页面界面设计,一般采用的是几个按钮加上不同的Fragment来切换页面,看起来层次很清晰,让用户一目了然,下面就用Fragment和RadioGroup来实现页面之间的切换,界面设计如下图所示:
代码如下:
titlebar.xml(Titlebar标题栏)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@android:color/holo_blue_light"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="标题"
android:textColor="@android:color/white"
android:textSize="20sp" />
</LinearLayout>
styles.xml
<resources>
...
<style name="bottom_tag_style" >
<!-- Customize your theme here. -->
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">1</item>
<item name="android:button">@android:color/transparent</item>
<item name="android:drawablePadding">3dp</item>
<item name="android:gravity">center</item>
<item name="android:textColor">@drawable/bottom_textcolor_drawable_selector</item>
<item name="android:textSize">10sp</item>
</style>
</resources>
bottom_textcolor_drawable_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false" android:color="#363636"/>
<item android:state_checked="true" android:color="#3097FD"/>
</selector>
activity_main.xml
主页面的布局,采用的是线性布局,头部是标题栏,中间是FrameLayout并且设置权重1,用来显示内容,底部是RadioGroup
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation=