《Android Studio开发实战》学习(五)- 调查问卷 - app:layout_constraintGuide_percent=&#34

📅 2026-11-30 👤 拼多多助力营销技巧 📂 手赚APP 👁️ 333 次阅读

《Android Studio开发实战》学习(五)- 调查问卷

背景

布局文件的设计

布局文件的编写

代码文件的编写

复选框CheckBox、开关按钮Switch和单选按钮RadioButton的使用

背景

在这里继续学习Android Studio 4.1.3的使用方法 1,学习复选框CheckBox、开关按钮Switch和单选按钮RadioButton的使用。

布局文件的设计

现在想要设计一个单页面按钮展示工具,包括4个复选框2,4个开关按钮,2个单选按钮,1个按钮。从上到下、从左到右的布局分别是

标题,宽度是100%,高度10%,用来展示标题文本“调查问卷”;

复选框,每个宽度50%,高度10%,两行两列,内容是个人爱好调查,包括吃、睡、唱歌、运动四项,以及一个标题“爱好”;

开关按钮,每个宽度50%,高度10%,两行两列,内容是手机设置,包括蓝牙、位置、移动数据、个人热点,以及一个标题“手机设置”;

单选按钮,每个宽度50%,高度10%,一行两列,内容是喜欢的歌手,包括杰克逊、麦当娜两项,以及一个标题“歌手”。

显示按钮,宽度100%,高度10%,单击后弹出消息框,显示个人爱好、开关状态、个人婚姻状况。

布局文件的编写

activity_main.xml的代码如下:

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"

tools:context=".MainActivity">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/guideline_1"

app:layout_constraintGuide_percent=".10"

android:orientation="horizontal"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/guideline_2"

app:layout_constraintGuide_percent=".20"

android:orientation="horizontal"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/guideline_3"

app:layout_constraintGuide_percent=".30"

android:orientation="horizontal"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/guideline_4"

app:layout_constraintGuide_percent=".40"

android:orientation="horizontal"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/guideline_5"

app:layout_constraintGuide_percent=".50"

android:orientation="horizontal"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/guideline_6"

app:layout_constraintGuide_percent=".60"

android:orientation="horizontal"/> 拼多多帮助力入口

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/guideline_7"

app:layout_constraintGuide_percent=".70"

android:orientation="horizontal"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/guideline_8"

app:layout_constraintGuide_percent=".80"

android:orientation="horizontal"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/guideline_9"

app:layout_constraintGuide_percent=".90"

android:orientation="horizontal"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/guideline_10"

app:layout_constraintGuide_percent=".50"

android:orientation="vertical"/>

android:id="@+id/tv_head"

android:layout_width="0dp"

android:layout_height="0dp"

android:gravity="center"

文章来源

标签: 拼多多助力网站平台 赚钱项目 拼多多助力网 首码项目 手赚APP
拼多多助力营销技巧