Android开发_1.布局

1.常见布局

  • 1.1 线性布局 LinearLayout
    右键–>创建Android XML File
根节点:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"//宽度,填充父框体
    android:layout_height="wrap_content"//高度,包裹内容
    android:gravity="center_horizontal" //里边控件的分布,水平居中
    android:orientation="horizontal" >//排列方式:水平、垂直
     <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:ems="10"
        android:inputType="textPersonName" >

        <requestFocus />
    </EditText>
</LinearLayout>
  • 1.2 相对布局
    RelativeLayout

  • 1.3 绝对布局

2.控件

  • 2.1 图片
 <ImageView 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher"/><!-- 图片路径 -->
  • 2.2 文本控件
<TextView
        android:inputType="textPassword" <!-- 输入内容分类,密码、数字(number)、电话号码(phone)等等 -->
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />
  • 2.3 复选框
<CheckBox
         android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
 方法:
 isChecked() //判断是否被选中,选中为true
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

holyZhang2021

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值