• Views Views 是所有可视元素的基类,所有的用户控件,包括布局类都继承于View
  • View Groups View Groups 是View类的扩展,可以包含多个View;可以使用ViewGroup类创建包含多个View的组合控件。
  • Activities 用来显示View,相当于Forms的概念。

Android 工具箱:

  • TextView 标准只读文本标签。
  • EditText 可以编辑输入的文本框。
  • ListView 创建和管理垂直方向列表的控件。
  • Spinner 是个组合控件,可以显示文本内容,并且可以从下拉列表中选择要显示的文本内容。(下拉列表控件)
  • Button 标准按钮
  • CheckBox 复选框
  • RadioButton 单选框
  • ViewFlipper 可以包含多个View 且View之间的切换有Animation
  • QuickContactBadge

Layouts 介绍

  • FrameLayout
  • LinearLayout
  • RelativeLayout
  • TableLayout
  • Gallery

Layout的使用

1.在xml中使用

<?xml version=”1.0″ encoding=”utf-8″?>
<LinearLayout xmlns:android=”
http://schemas.android.com/apk/res/android”
android:orientation=”vertical”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”>
<TextView
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”Enter Text Below”
/>
<EditText
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”Text Goes Here!”
/>
</LinearLayout>

2.在代码中使用

LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
TextView myTextView = new TextView(this);
EditText myEditText = new EditText(this);

myTextView.setText(“Enter Text Below”);
myEditText.setText(“Text Goes Here!”);
int lHeight = LinearLayout.LayoutParams.FILL_PARENT;
int lWidth = LinearLayout.LayoutParams.WRAP_CONTENT;
ll.addView(myTextView, new LinearLayout.LayoutParams(lHeight, lWidth));
ll.addView(myEditText, new LinearLayout.LayoutParams(lHeight, lWidth));
setContentView(ll);

3.Layout要注意到的事

  • 避免不必要的View嵌套
  • 避免使用过多的View
  • 避免嵌套层次过多

更多相关文章

  1. android学习小结3-各种控件使用方式DEMO
  2. Android学习笔记-Android非布局activity中布局文件及控件加载方
  3. Android Studio高级控件(自动提示文本框)
  4. Android 分页控件制成底部菜单.
  5. android 控件学习---------GridView
  6. Android 控件之Gallery和ImageSwitcher图片切换器

随机推荐

  1. Android(安卓)解析jwt遇到java.lang.Ille
  2. 在做Android中GIF遇到不能显示的问题
  3. 图文详解Android属性动画
  4. Android高手应该精通哪些内容?
  5. Android学习之sqlit
  6. Android中使用log4j输出log内容到sd卡
  7. android 退出应用程序
  8. windows系统上安装与使用Android(安卓)ND
  9. [Google Android] 理解NDK(1)-- 编译Androi
  10. Android入门教程 AsyncTask的使用及execu