2-1 View与ViewGroup的概念

介绍

学习

在Android APP中,所有的用户界面元素都是由View和ViewGroup的对象构成的。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <LinearLayout
        android:id="@+id/ll_1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#fff"
        android:orientation="horizontal">

   <TextView
       android:id="@+id/text1"
       android:text="测试代码"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       />
    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:text="提交"
         android:layout_height="30dp"/>
    </LinearLayout>
</LinearLayout>

    <!--
    线性布局:
    android:orientation="vertical"  纵轴排列
    android:orientation="horizontal" 横轴排列
    -->

无需全部用View和ViewGroup对象来创建你的UI布局。Android给我们提供了一些app控件,标准的UI布局,你只需要定义内容。这些UI组件都有其属性介绍的API文档,比如操作栏,对话框和状态通知栏等

posted @ 2022-02-25 14:05  禾耳  阅读(36)  评论(0)    收藏  举报