今天群里聊天说是实现白天夜晚模式切换不好搞,网上看了一下净是些设置theme的。仔细想了一下,白天夜晚模式的切换无非就是重新设置空间的背景色与字体颜色,如果这样的话,用broadcast receiver不是一个很好的实现方式吗?
上代码:
新建一个工程DayAndNightDemo。打开fragment_main.xml添加一个Button.
<RelativeLayout xmlns:a...
分类:
移动开发 时间:
2015-01-19 12:53:35
阅读次数:
142
一、布局文件实现步骤:
1、在res/layout目录下创建一个demo_layout.xml布局文件,
2、使用RelativeLayout嵌套一个LinearLayout来进行布局,往里添加一个TextView和两个Button,并设置属性。
3、创建一个FirstLayoutActivity类,在onCreateView()方法中,使用findViewById()实例化组件。
4.A...
分类:
移动开发 时间:
2015-01-19 09:20:07
阅读次数:
292
(1)文件的目录
(2)各文件的代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
andr...
分类:
移动开发 时间:
2015-01-18 18:36:59
阅读次数:
246
一贯作风,先看效果图,再实现
编写自定义属性文件atts.xml,自定义属性中涉及到的属性有左右两边的button的背景图,中间标题的内容,字体大小,字体颜色。
编写布局文件layout_topbar.xml,使用相对布局,左边一个button,跟父控件左对齐后外边距...
分类:
移动开发 时间:
2015-01-18 17:12:31
阅读次数:
282
(1)目录结构
(2) 布局文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
androi...
分类:
移动开发 时间:
2015-01-18 14:24:30
阅读次数:
187
(1)布局文件,一个简单的登录文件;
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:la...
分类:
移动开发 时间:
2015-01-17 20:56:16
阅读次数:
273
(1)在布局文件中创建一个listview:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
androi...
分类:
移动开发 时间:
2015-01-17 15:16:03
阅读次数:
229
(1)布局文件:用于弹出菜单的处罚button:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
andr...
分类:
移动开发 时间:
2015-01-17 15:14:34
阅读次数:
199
最近在遇到RelativeLayout里的gravity属性给它复制center_horizontal或者center都不能居中它的子组件,后来找到了替代方法,只要在它的每个子组件里加上android:layout_centerHorizontal="true"就可以了摘自:http://blog....
分类:
其他好文 时间:
2015-01-17 12:36:02
阅读次数:
222
(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...
分类:
移动开发 时间:
2015-01-16 19:18:58
阅读次数:
178