一、对齐方式
1.控件位置
示例代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
// 省略
<Button
android:id="@+id/experience"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="立即体验"
android:textColor="@color/font_white"
android:layout_centerHorizontal="true"
android:background="@drawable/login_button_bg"
android:layout_above="@id/ll_guide"
android:layout_marginBottom="35dp"/>
</RelativeLayout>
android:layout_centerHorizontal:控制该组件是否位于布局容器的水平居中位置
android:layout_centerVertical:控制该组件是否位于布局容器的垂直居中位置
android:layout_centerInParent:控制该组件是否位于布局容器的中央位置
android:layout_alignParentBottom:控制该组件是否与布局容器底端对齐
android:layout_alignParentLeft:控制该组件是否与布局容器左边对齐
android:layout_alignParentRight:控制该组件是否与布局容器右边对齐
android:layout_alignParentTop:控制该组件是否与布局容器顶端对齐
android:layout_alignTop:控制该组件与给出ID组件的上边界对齐
android:layout_alignBottom:控制该组件与给出ID组件的下边界对齐
android:layout_alignLeft:控制该组件与给出ID组件的左边界对齐
android:layout_alignRight:控制该组件与给出ID组件的右边界对齐
android:layout_toRightOf:控制该组件位于给出ID组件的右侧
android:layout_toLeftOf:控制该组件位于给出ID组件的左侧
android:layout_above:控制该组件位于给出ID组件的上方
android:layout_below:控制该组件位于给出ID组件的下方
2.水平居中
参考链接:
让android控件水平居中 - findsafety的专栏 - 博客频道 - youkuaiyun.com
http://blog.youkuaiyun.com/findsafety/article/details/8789158
二、引入Android原生库的布局
1.TabLayout的使用
仿优快云客户端首页(一)----TabLayout实现选项卡滑动效果 - Young_Kai - 博客频道 - youkuaiyun.com
http://blog.youkuaiyun.com/tyk0910/article/details/51395064
TabLayout的简单使用 - 我本无名的专栏 - 博客频道 - youkuaiyun.com
http://blog.youkuaiyun.com/chenguang79/article/details/48804125
Design库-TabLayout属性详解 - darling_R的博客 - 博客频道 - youkuaiyun.com
http://blog.youkuaiyun.com/darling_r/article/details/52439460
三、selector背景选择器
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true" android:drawable="@mipmap/point_not_selected"/>
<item android:state_enabled="false" android:drawable="@mipmap/point_selected"/>
</selector>
android:state_enabled表示能够接受触摸或者点击事件。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 按下边框变白色 -->
<item android:state_pressed="true">
<shape>
<corners android:radius="100dp"/>
<stroke
android:width="1dp"
android:color="@color/white" />
</shape>
</item>
<item android:state_enabled="false">
<shape>
<corners android:radius="100dp"/>
<stroke
android:width="1dp"
android:color="@color/green_theme" />
</shape>
</item>
</selector>