zoukankan      html  css  js  c++  java
  • Android UI 介绍1

    • 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
    • 避免嵌套层次过多
  • 相关阅读:
    android模拟器中文乱码
    Broadcast Receviewer
    Spring XML配置里的Bean自动装配
    Spring中的Bean配置
    Spring第一个helloWorld
    MyBatis向数据库中批量插入数据
    MyBatis联合查询和使用association 进行分步式查询
    MyBatis编写映射文件实现增删改操作 附说明及代码
    MyBatis全局配置文件MyBatis-config.xml代码
    MyBatis全局配置文件mybatis-config.xml
  • 原文地址:https://www.cnblogs.com/zjmsky/p/1898751.html
Copyright © 2011-2022 走看看