Android学习笔记1 创建一个activity
2014-03-24 11:40
302 查看
内容均为google官方教程的学习笔记
教程地址:http://developer.android.com/intl/zh-cn/training/basics/firstapp/building-ui.html#LinearLayout
实际运行效果
要点:
1 对view可以指定宽度和长度为wrap_content, 即view可以根据其content的长宽来动态适应. 比如上图的text里的输入, 如果换行, 也会撑大text的高度.
2 线性布局中可以用weight属性来分配和填充布局的剩余空间, 如果只有一个view设置了weight, 那就会填充满剩余空间, 需要注意的是设置weight后需要指定宽度为0, 即不再需要固定宽度.
教程地址:http://developer.android.com/intl/zh-cn/training/basics/firstapp/building-ui.html#LinearLayout
<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" android:orientation="horizontal" > <EditText android:id="@+id/edit_message" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/edit_message" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button_send" /> </LinearLayout>
实际运行效果
要点:
1 对view可以指定宽度和长度为wrap_content, 即view可以根据其content的长宽来动态适应. 比如上图的text里的输入, 如果换行, 也会撑大text的高度.
2 线性布局中可以用weight属性来分配和填充布局的剩余空间, 如果只有一个view设置了weight, 那就会填充满剩余空间, 需要注意的是设置weight后需要指定宽度为0, 即不再需要固定宽度.
相关文章推荐
- Android学习笔记(一):创建一个Activity
- fragment向activity传递数据时fragment创建一个回调接口
- 【Android】使用Intent实现Activity之间的跳转(创建一个Activity的过程)
- Android学习笔记——Android Studio创建Activity
- 点击Notification正确回调到之前已经放置在后台的Task中的对应Activity,而不是创建它的一个新实例
- Android程序 类QQ通知常驻在Notification栏 点击Notification正确回调到之前已经放置在后台的Task中的对应Activity,而不是创建它的一个新实例
- Android学习笔记(九)—— 调用另外一个Activity — Intent对象的使用
- 16 activity 详解001 在activity中创建里一个activity
- Activity生命周期 之 重新创建一个Activity
- Android开发系列(一) 创建一个Activity的基本流程
- Dialog基础(在一个Activity中创建多个Dialog)
- 如何创建一个Activity,两个Activity 之间如何通讯
- android 如何创建一个非全荧幕的Activity
- 创建你的第一个安卓应用4 - 第四课 - 启动另外一个activity
- 创建一个Android Activity
- 从桌面图标启动一个LauncherMode为标准模式的主activity为什么不会重复创建多个实例
- 如何创建一个baseActivity,让你的代码更优雅
- Android 创建一个activity 及创建Intent对象跳转界面并传值
- Android Transition 和 Activity & Fragment Transition详解(三)--从创建一个Scene开始
- 安卓入门 使用android创建一个项目 从启动activity中响应按钮事件 启动另一个activity 并传递参数