20161207(Android UI)
来源:互联网 发布:linux gradle 下载 编辑:程序博客网 时间:2024/06/06 02:12
一、布局:
1、线性布局:LinearLayout
子元素排列方式
android:orientation=”vertical” 垂直排列
=”horizontal” 水平排列
填满其父元素:
android:layout_width=”fill_parent”
该元素的大小仅包裹其自身内容:
android:layout_height=”wrap_content”
2、相对布局:RelativeLayout
将该元素放到id为text的元素下面
android:layout_below=”@id/text”
放到id为cancel的元素左边
android:layout_toLeftOf=”@id/cancel”
对齐id为cancel元素的顶部
android:layout_alignTop=”@id/cancel”
将控件的左边缘和父控件的左边缘对齐
android:layout_alignParentLeft=”true”
3、表格布局:TableLayout
4、帧布局:FrameLayout
二、常用控件
1、单选框:RadioButton
设置默认选定
android:checkedButton=”@+id/woman”
2、多选框:CheckBox
3、列表显示:ListView
private ListView listView;
private String[] name = {“张三”,”李四”,”王五”};
@Overrideprotected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); listView = (ListView) findViewById(R.id.lv_listView); //创建一个ArrayAdapter ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,name); listView.setAdapter(adapter); //listView注册一个元素单击事件监听器 listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Toast.makeText(MainActivity.this,name[arg2],Toast.LENGTH_LONG).show(); } });}
PS:EditText会默认得到焦点,想取消它的焦点可以在布局上添加
android:focusable=”true”
android:focusableInTouchMode=”true”使焦点到布局上
- 20161207(Android UI)
- Android UI
- Android ui
- Android UI
- android UI
- android UI
- android UI
- android UI
- android UI
- Android UI
- Android UI
- android UI
- Android UI
- Android UI
- android ui
- android UI
- Android UI
- Android UI
- js中location.search、split()HTML5中localStorage
- (EM算法)The EM Algorithm
- c#简单的就业调查表
- Git 操作记录整理
- 机试之坐标移动
- 20161207(Android UI)
- 用c写python的拓展模块
- Ubuntu 默认用root登录设置
- 设计模式教程-开闭原则OCP
- Redis集群环境搭建-cluster模式
- 静态内部类
- rxjava2.0+retrofit2.0初试水,小demo
- C#基础-为什么引入委托
- error when loading the sdk 发现了元素 d:skin 开头无效内容