我打算做个相对布局的模型,之后基于这个模型进行一系列的学习【包括横竖屏、控件动画等】,实现一些简单的功能,加深对一些理论的实践性的理解;一步一步来吗!
这个就是今天的一个小效果,感谢网友的分享,让我学到了很多,最重要的一点就是当我发现效果和想的不一样的时候,开始找资料,各种试试,然后回过头来看手册的参数说明,才想到设置一个参数就能解决问题,此时还是很高兴的,体会过程,都是经验啊!!!
总体效果就是这样【UI很丑】:

相对布局文件【文中注释的地方就是后来发现需要这样才可以达到效果、菜鸟一个、所以才纠结这么久】:res/layout/center.xml
点击(此处)折叠或打开
-
<?xml version="1.0" encoding="utf-8"?>
-
<LinearLayout xmlns:android=""
-
android:layout_width="fill_parent"
-
android:layout_height="fill_parent"
-
android:orientation="vertical"
-
android:background="@drawable/back_ground" >
-
-
<RelativeLayout
-
android:id="@+id/RelativeLayout_with_center"
-
android:layout_width="fill_parent"
-
android:layout_height="fill_parent" >
-
-
<!-- 屏幕中心按钮设置 android:layout_centerInParent="true" -->
-
<Button
-
android:id="@+id/center_menu_button"
-
android:layout_width="wrap_content"
-
android:layout_height="wrap_content"
-
android:layout_centerInParent="true"
-
android:background="@drawable/button" />
-
-
<!-- 屏幕中心按钮左侧按钮,此时需要设置垂直居中 android:layout_centerVertical="true" -->
-
<Button
-
android:id="@+id/left_button"
-
android:layout_width="wrap_content"
-
android:layout_height="wrap_content"
-
android:layout_centerVertical="true"
-
android:layout_toLeftOf="@+id/center_menu_button"
-
android:background="@drawable/round_button"
-
android:text="亲,评价" />
-
-
<!-- 屏幕中心按钮右侧侧按钮,此时需要设置垂直居中 android:layout_centerVertical="true" -->
-
<Button
-
android:id="@+id/right_button"
-
android:layout_width="wrap_content"
-
android:layout_height="wrap_content"
-
android:layout_centerVertical="true"
-
android:layout_toRightOf="@+id/center_menu_button"
-
android:background="@drawable/round_button"
-
android:text="退出游戏" />
-
-
<!-- 屏幕中心按钮上方按钮,此时需要设置水平居中 android:layout_centerHorizontal="true" -->
-
<Button
-
android:id="@+id/top_button"
-
android:layout_width="wrap_content"
-
android:layout_height="wrap_content"
-
android:layout_centerHorizontal="true"
-
android:layout_above="@+id/center_menu_button"
-
android:background="@drawable/round_button"
-
android:text="进入游戏" />
-
-
<!-- 屏幕中心按钮下方按钮,此时需要设置水平居中 android:layout_centerHorizontal="true" -->
-
<Button
-
android:id="@+id/below_button"
-
android:layout_width="wrap_content"
-
android:layout_height="wrap_content"
-
android:layout_centerHorizontal="true"
-
android:layout_below="@+id/center_menu_button"
-
android:background="@drawable/round_button"
-
android:text="关于我们" />
-
</RelativeLayout>
-
- </LinearLayout>
点击(此处)折叠或打开
-
<?xml version="1.0" encoding="utf-8"?>
-
<selector xmlns:android="" >
-
<!-- 获得焦点但未按下时的背景图片 -->
-
<!-- <item android:state_focused="true" android:state_enabled="true" android:state_pressed="false" android:drawable="@drawable/user_selecte_n" /> -->
-
<!-- 按下时的背景图片 -->
-
<item android:state_enabled="true" android:state_pressed="true" android:drawable="@drawable/center_light" />
-
<!-- 按下时的背景图片 -->
-
<!-- <item android:state_enabled="true" android:state_checked="true" android:drawable="@drawable/center_light" /> -->
-
<!-- 默认时的背景图片 -->
-
<item android:drawable="@drawable/center" />
- </selector>
点击(此处)折叠或打开
-
<?xml version="1.0" encoding="UTF-8"?>
-
<selector xmlns:android="">
-
<item android:state_pressed="false">
-
<shape android:shape="rectangle" >
-
<!-- 填充的颜色 -->
-
<solid android:color="#0FFFFF" />
-
<!-- 设置按钮的四个角为弧形 -->
-
<!-- android:radius 弧形的半径 -->
-
<corners android:radius="15dip" />
-
<!-- padding:Button里面的文字与Button边界的间隔 -->
-
<padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />
-
</shape>
-
</item>
-
<item android:state_pressed="true">
-
<shape android:shape="rectangle">
-
<solid android:color="#FFFF0F" />
-
<corners android:radius="15dip" />
-
</shape>
-
</item>
- </selector>