Layout

Basic command:
   1: string $layoutName= <insert name of layout here>;
   2: layout -edit -width 200 $layoutName;
   3: layout -query -numberOfChildren $layoutName;
   4: layout -exists $layoutName;
ColumnLayout
   1: window;
   2:     columnLayout -columnAttach "both" 12 -rowSpacing 8 -columnWidth 150 -adjustableColumn true;
   3:         button;
   4:         button;
   5: showWindow;

1

RowLayout
   1: window;
   2:     rowLayout -numberOfColumns 3 -columnWidth3 100 60 80 -columnAttach 1 "both" 0;
   3:         button;
   4:         button;
   5:         button;
   6: showWindow;

2

In the row layout, the number of column must be explicitly defined.

GridLayout
   1: window;
   2:     gridLayout -numberOfRowsColumns 2 2 -cellWidthHeight 60 50 mygrid;
   3:         button;
   4:         button;
   5:         button;
   6: showWindow;

3 

use -position can reposition the child elements, but I have not succeed. Every time, an error " Object is not the child" prompt out, I do not know why.

FormLayout
   1: window;
   2:     string $form=`formLayout -numberOfDivisions 100`;
   3:     string $but1=`button`;
   4:     string $but2=`button`;
   5:     string $but3=`button`;
   6:     formLayout -edit
   7:         // Button 1
   8:         -attachForm $but1 "top" 0
   9:         -attachForm $but1 "left" 0
  10:         -attachForm $but1 "bottom" 0
  11:         -attachPosition $but1 "right" 0 50
  12:         // Button 2
  13:         -attachForm $but2 "right" 0
  14:         // Button 3
  15:         -attachPosition $but3 "top" 0 5
  16:         -attachControl $but3 "left" 5 $but1
  17:         $form;
  18: showWindow;

4

The position of every element in form layout must be explicitly specified. Usually, the general procedure to add all the child elements to the form layout and then use its editing feature to finally position them.

FrameLayout

The layout that can expand and collapse.

   1: window;
   2:     frameLayout -label "Settings" -borderStyle "etchedIn" 
   3:         -font "obliqueLabelFont" -collapsable true;
   4:         columnLayout;
   5:             button;
   6:             button;
   7:             button;
   8: showWindow;

5

TabLayout

The tab layout allows you to organize other layouts into a series of folders. All the children of a tabLayout must be layouts.

   1: window;
   2:     string $tabs=`tabLayout`;
   3:     string $tab1=`columnLayout`;
   4:         button;
   5:         setParent ..;
   6:     string $tab2=`columnLayout`;
   7:         button;
   8:         setParent ..;
   9:     tabLayout -edit
  10:         -tabLabel $tab1 "Colors"
  11:         -tabLabel $tab2 "Flavors"
  12:         $tabs;
  13: showWindow;

6

ScrollLayout
   1: window;
   2:     scrollLayout;
   3:         columnLayout;
   4:             button;
   5:             button;
   6:             button;
   7:             button;
   8: showWindow;

7

MenubarLayout
   1: window;
   2:     menuBarLayout;
   3:         menu -label "File";
   4:             menuItem -label "Exit";
   5:         menu -label "Help" -helpMenu true;
   6:             menuItem -label "About...";
   7:         setParent ..;
   8:     string $tabs=`tabLayout`;
   9:     string $tabl=`menuBarLayout`;
  10:         menu -label "colors";
  11:             menuItem -label "Red";
  12:             menuItem -label "Green";
  13:         menu -label "Flavors";
  14:             menuItem -label "Vanilla";
  15:             menuItem -label "Chocolate";
  16:         tabLayout -edit -tabLabel $tabl "Confectionary" $tabs;
  17: showWindow;

8

那接下来几个界面也像这样修改成这种形式,只用最小量修改。首先是fragment_home.xml:<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout 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" tools:context=".ui.home.HomeFragment" android:fitsSystemWindows="true" android:background="@color/surface_background"> <!-- 🔍 输入框 --> <EditText android:id="@+id/home_input" android:layout_width="0dp" android:layout_height="wrap_content" android:hint="请输入需要查询的公交线路或站点" android:textColorHint="#777777" android:textColor="@color/black" android:background="@drawable/rounded_edittext" android:minHeight="48dp" android:textSize="16sp" android:padding="12dp" app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toStartOf="@id/home_search" app:layout_constraintHorizontal_chainStyle="packed" android:layout_marginStart="16dp" android:layout_marginEnd="8dp" android:layout_marginTop="88dp" /> <!-- 🔎 搜索按钮 --> <Button android:id="@+id/home_search" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="搜索" app:layout_constraintTop_toTopOf="@id/home_input" app:layout_constraintBottom_toBottomOf="@id/home_input" app:layout_constraintStart_toEndOf="@id/home_input" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="16dp" /> <!-- 🚌 图片:居中偏上 --> <ImageView android:id="@+id/image_bus" android:layout_width="wrap_content" android:layout_height="wrap_content" android:scaleType="fitCenter" android:src="@drawable/bus" app:layout_constraintTop_toBottomOf="@id/home_input" app:layout_constraintBottom_toTopOf="@+id/text_home" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" android:layout_marginTop="144dp" android:layout_marginBottom="144dp"/> <!-- ℹ️ 底部说明文字 --> <TextView android:id="@+id/text_home" android:textColor="#777777" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:textAlignment="center" android:textSize="11sp" app:layout_constraintTop_toBottomOf="@id/image_bus" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toBottomOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> 其次是fragment_map.xml:<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout 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" tools:context=".ui.map.MapFragment" android:fitsSystemWindows="true" android:background="@color/surface_background"> <androidx.constraintlayout.widget.Guideline android:id="@+id/guideline_top_offset" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" app:layout_constraintGuide_percent="0.015" /> <!-- 🔹 起点输入框 --> <EditText android:id="@+id/map_input1" android:layout_width="0dp" android:layout_height="48dp" android:hint="请输入起点" android:textColorHint="#777777" android:textColor="@color/black" android:background="@drawable/rounded_edittext" android:padding="12dp" android:layout_marginStart="16dp" android:layout_marginEnd="8dp" android:layout_marginTop="32dp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toStartOf="@id/guideline_search" app:layout_constraintTop_toTopOf="@id/guideline_top_offset" /> <!-- 🔹 终点输入框 --> <EditText android:id="@+id/map_input2" android:layout_width="0dp" android:layout_height="48dp" android:hint="请输入终点" android:textColorHint="#777777" android:textColor="@color/black" android:background="@drawable/rounded_edittext" android:padding="12dp" android:layout_marginStart="16dp" android:layout_marginEnd="8dp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toStartOf="@id/guideline_search" app:layout_constraintTop_toBottomOf="@id/map_input1" /> <!-- ✅ 分割线:75% 处(原样保留) --> <androidx.constraintlayout.widget.Guideline android:id="@+id/guideline_search" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" app:layout_constraintGuide_percent="0.75" /> <!-- 🔍 搜索按钮:纵向拉高,覆盖两个输入框 --> <Button android:id="@+id/map_search" android:layout_width="0dp" android:layout_height="0dp" android:text="搜索" android:textSize="16sp" android:gravity="center" app:layout_constraintStart_toStartOf="@id/guideline_search" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="@id/map_input1" app:layout_constraintBottom_toBottomOf="@id/map_input2" android:layout_marginEnd="16dp" /> <!-- 🗺️ 地图视图:从终点输入框下方开始,延伸到底部 --> <com.amap.api.maps.MapView android:id="@+id/map_view" android:text="Bus-1.0" android:textColor="#777777" android:layout_width="0dp" android:layout_height="0dp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/map_input2" app:layout_constraintBottom_toBottomOf="parent" android:layout_marginTop="4dp" android:layout_marginBottom="0dp"/> </androidx.constraintlayout.widget.ConstraintLayout> 接着是fragment_settings.xml:<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout 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" tools:context=".ui.settings.SettingsFragment" android:fitsSystemWindows="true" android:background="@color/surface_background"> <!-- 🔹 Material Design 按钮组 --> <Button android:id="@+id/btn_gps" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="权限设置" app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" android:layout_marginStart="16dp" android:layout_marginEnd="16dp" android:layout_marginTop="56dp" /> <Button android:id="@+id/btn_apps" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="关于公交查询系统" app:layout_constraintTop_toBottomOf="@id/btn_gps" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" android:layout_marginStart="16dp" android:layout_marginEnd="16dp" android:layout_marginTop="16dp" /> <Button android:id="@+id/btn_user" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="用户调研" app:layout_constraintTop_toBottomOf="@id/btn_apps" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" android:layout_marginStart="16dp" android:layout_marginEnd="16dp" android:layout_marginTop="16dp" /> <Button android:id="@+id/btn_exit" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="退出程序" app:layout_constraintTop_toBottomOf="@id/btn_user" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" android:layout_marginStart="16dp" android:layout_marginEnd="16dp" android:layout_marginTop="16dp" /> <!-- 🔹 图片:放在按钮下方 --> <ImageView android:id="@+id/image_bus" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="64dp" android:layout_marginBottom="64dp" android:src="@drawable/bus" app:layout_constraintBottom_toTopOf="@+id/text_settings" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/btn_exit" /> <!-- 🔹 底部 TextView --> <TextView android:id="@+id/text_settings" android:text="Bus-1.0" android:textColor="#777777" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:textAlignment="center" android:textSize="11sp" app:layout_constraintTop_toBottomOf="@id/image_bus" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toBottomOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> 还有activity_survey.xml:<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="16dp" android:fitsSystemWindows="true" android:background="@color/surface_background"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <!-- 问题1:评分 --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:layout_marginBottom="32dp" android:text="🚌 用户体验调研" android:textColor="#777777" android:textSize="24sp" android:textStyle="bold" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="1. 您对本应用的整体评分是?" android:textStyle="bold" android:textColor="#777777" android:layout_marginBottom="8dp" /> <RadioGroup android:id="@+id/radioGroupRating" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="24dp"> <RadioButton android:text="⭐ 1分 - 非常不满意" android:textColor="@color/black" android:id="@+id/rb1" android:layout_height="match_parent" android:layout_width="match_parent"/> <RadioButton android:text="⭐⭐ 2分 - 不满意" android:textColor="@color/black" android:id="@+id/rb2" android:layout_height="match_parent" android:layout_width="match_parent"/> <RadioButton android:text="⭐⭐⭐ 3分 - 一般" android:textColor="@color/black" android:id="@+id/rb3" android:layout_height="match_parent" android:layout_width="match_parent"/> <RadioButton android:text="⭐⭐⭐⭐ 4分 - 满意" android:textColor="@color/black" android:id="@+id/rb4" android:layout_height="match_parent" android:layout_width="match_parent"/> <RadioButton android:text="⭐⭐⭐⭐⭐ 5分 - 非常满意" android:textColor="@color/black" android:id="@+id/rb5" android:layout_height="match_parent" android:layout_width="match_parent"/> </RadioGroup> <!-- 问题2:满意度 --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="2. 您对以下哪些方面或功能感到满意?(可多选)" android:textColor="#777777" android:textStyle="bold" android:layout_marginBottom="8dp" /> <CheckBox android:id="@+id/cb_ui" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="界面美观易用" android:textColor="@color/black"/> <CheckBox android:id="@+id/cb_speed" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="加载速度快" android:textColor="@color/black"/> <CheckBox android:id="@+id/cb_information" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="查询信息准确" android:textColor="@color/black"/> <CheckBox android:id="@+id/cb_other" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="其他" android:textColor="@color/black"/> <!-- 问题3:建议 --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="3. 您有什么改进建议?" android:textColor="#777777" android:textStyle="bold" android:layout_marginTop="24dp" android:layout_marginBottom="8dp" /> <EditText android:id="@+id/et_suggestion" android:layout_width="match_parent" android:layout_height="120dp" android:gravity="top" android:hint="请输入您的建议..." android:textColorHint="#777777" android:textColor="@color/black" android:inputType="textMultiLine" android:minLines="3" /> <!-- 提交按钮 --> <Button android:id="@+id/btn_submit" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="提交反馈" android:textSize="18sp" android:layout_marginTop="32dp" style="?android:attr/buttonStyle" /> </LinearLayout> </ScrollView> 和activity_about.xml:<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center" android:padding="20dp" android:fitsSystemWindows="true" android:background="@color/surface_background"> <!-- 软件名称 --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="公交查询系统" android:textSize="28sp" android:textStyle="bold" android:textColor="#000" android:layout_marginBottom="10dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Bus" android:textSize="18sp" android:textColor="#555555" android:layout_marginBottom="80dp" /> <!-- 软件图片 --> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/bus" android:layout_marginBottom="100dp"/> <!-- 版本信息 --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="版本:1.0" android:textSize="16sp" android:textColor="#777777" android:layout_marginBottom="20dp" /> <!-- 开发信息 --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="开发团队:white luminous" android:textSize="16sp" android:textColor="#777777" android:layout_marginBottom="10dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="邮箱:support@busapp.cn" android:textColor="#777777" android:textSize="16sp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="hao" android:textSize="8sp" android:layout_marginTop="100dp" android:textColor="#EEE"/> </LinearLayout> 以及activity_route_plan.xml: <!-- res/layout/activity_route_plan.xml --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:fitsSystemWindows="true" android:background="@color/surface_background"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="正在规划公交路线..." android:textSize="16sp" android:gravity="center" android:padding="16dp" android:textColor="#555" /> <com.amap.api.maps.MapView android:id="@+id/map_view" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout>
最新发布
11-07
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值