Android stduio界面控件依次是姓名、年龄、身高
时间: 2024-02-02 07:02:36 浏览: 72
在Android Studio界面中,可以使用以下控件来实现姓名、年龄和身高输入:
1. EditText控件:用于输入文本内容,可以用来输入姓名、年龄和身高。
2. TextView控件:用于显示静态文本内容,可以用来显示标签,如“姓名”、“年龄”、“身高”。
3. Button控件:用于触发某些事件,比如保存输入的信息。
4. LinearLayout控件:用于将以上控件按照水平或垂直方向排列。
5. ScrollView控件:用于在屏幕空间不够时,提供滚动功能,以便查看所有控件。
以下是一种实现方式:
```xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">
<!--姓名输入框-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="姓名:"/>
<EditText
android:id="@+id/et_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入姓名"/>
<!--年龄输入框-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="年龄:"/>
<EditText
android:id="@+id/et_age"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入年龄"/>
<!--身高输入框-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="身高:"/>
<EditText
android:id="@+id/et_height"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入身高"/>
<!--保存按钮-->
<Button
android:id="@+id/btn_save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="保存"/>
</LinearLayout>
</ScrollView>
```
在代码中,可以通过findViewById()方法获取输入框和按钮控件的引用,然后在按钮的点击事件中获取输入框的内容,进行保存或其他操作。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)