Android:基本 UI 组件

这篇博客介绍了Android应用程序设计中的基本UI组件,包括文本类组件如TextView和EditText,用于显示和输入文本。此外,还详细讲解了按钮类组件,如Button、ImageButton、RadioButton和CheckBox,它们各自在触发事件和用户交互中的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前言

组件是 Android 程序设计的基本组成单元,通过使用组件可以高效地开发 Android 应用程序。

文本类组件

Android 中提供了一些与文本显示、输入相关的组件,通过这些组件可以显示或输入文字。
TextView 类:用于显示文本的组件为文本框组件。
EditText 类:允许用户编辑文本内容。

举例说明:编辑框

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    android:background="#EAEAEA"
    tools:context=".MainActivity">

    <!-- 添加写说说编辑框 -->
    <EditText
        android:id="@+id/edit"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:background="#FFFFFF"
        android:gravity="top"
        android:hint="说点什么吧..."
        android:inputType="textMultiLine"
        android:lines="6"
        android:padding="5dp"></EditText>

    <ImageView
        android:id="@+id/picture"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_below="@&#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值