Android移动应用开发UI界面练习

目录

例题分析

代码实现 

实际效果 


例题分析

参考百词斩app,打开界面如下,大致画一下UI界面的结构。

代码实现 

<?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">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="120dp">
        <View
            android:id="@+id/view_1"
            android:layout_width="30dp"
            android:layout_height="40dp"
            android:background="#d9ead3"
            android:layout_marginVertical="10dp"
            android:layout_marginLeft="10dp"/>

        <View
            android:id="@+id/view_2"
            android:layout_width="290dp"
            android:layout_height="40dp"
            android:layout_toRightOf="@id/view_1"
            android:background="#d9ead3"
            android:layout_marginHorizontal="17dp"
            android:layout_marginVertical="10dp"/>

        <View
            android:id="@+id/view_3"
            android:layout_width="35dp"
            android:layout_height="40dp"
            android:layout_toRightOf="@id/view_2"
            android:background="#d9ead3"
            android:layout_marginVertical="10dp"
            android:layout_marginRight="10dp"/>

        <View
            android:id="@+id/view_4"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_below="@id/view_3"
            android:layout_margin="8dp"
            android:layout_marginStart="5dp"
            android:background="#bfedae" />
    </RelativeLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:background="#3c78d8"
        android:orientation="vertical">
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <View
                    android:id="@+id/view_5"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:layout_margin="15dp"
                    android:background="#c9daf8"/>

                <View
                    android:id="@+id/view_6"
                    android:layout_width="300dp"
                    android:layout_height="50dp"
                    android:layout_margin="15dp"
                    android:layout_toRightOf="@id/view_5"
                    android:background="#c9daf8" />

                <View
                    android:id="@+id/view_7"
                    android:layout_width="380dp"
                    android:layout_height="90dp"
                    android:layout_below="@id/view_6"
                    android:layout_marginStart="15dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginEnd="10dp"
                    android:layout_marginBottom="10dp"
                    android:background="#c9daf8" />
            </RelativeLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="10dp"
        android:background="#fff2cc"
        android:orientation="vertical">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <View
                android:id="@+id/view_8"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_margin="15dp"
                android:background="#ed9494"/>

            <View
                android:id="@+id/view_9"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_margin="15dp"
                android:layout_toRightOf="@id/view_8"
                android:background="#ed9494"/>

            <View
                android:id="@+id/view_10"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_margin="15dp"
                android:layout_toRightOf="@id/view_9"
                android:background="#ed9494"/>

            <View
                android:id="@+id/view_11"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_margin="15dp"
                android:layout_toRightOf="@id/view_10"
                android:background="#ed9494"/>

            <View
                android:id="@+id/view_12"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_margin="15dp"
                android:layout_toRightOf="@id/view_11"
                android:background="#ed9494"/>

            <View
                android:id="@+id/view_13"
                android:layout_width="380dp"
                android:layout_height="60dp"
                android:layout_below="@id/view_9"
                android:layout_marginStart="15dp"
                android:layout_marginTop="8dp"
                android:layout_marginEnd="15dp"
                android:layout_marginBottom="15dp"
                android:background="@color/white" />

            <View
                android:id="@+id/view_14"
                android:layout_width="380dp"
                android:layout_height="60dp"
                android:layout_below="@id/view_13"
                android:layout_marginStart="15dp"
                android:layout_marginTop="3dp"
                android:layout_marginEnd="15dp"
                android:background="@color/white" />

        </RelativeLayout>


    </LinearLayout>


</LinearLayout>

实际效果 

颜色取色器网站:在线颜色选择器 | RGB颜色查询对照表

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当涉及到Android开发的UI界面布局教学,有几个重要的概念和技术需要了解。下面我会介绍一些常用的布局方式和相关的教学资源。 1. 线性布局(LinearLayout):线性布局是最常用的布局方式之一,它可以使组件在水平或垂直方向上按照一定的顺序排列。你可以使用`android:orientation`属性来指定布局的方向。详细教程请参考CSDN的[Android开发之线性布局详解](https://blog.csdn.net/u013831257/article/details/52539859)。 2. 相对布局(RelativeLayout):相对布局允许你根据其他组件的位置和关系来定位组件。你可以使用各种规则(如`android:layout_alignParentTop`、`android:layout_below`等)来指定组件相对于父组件或其他组件的位置。详细教程请参考CSDN的[Android开发之相对布局详解](https://blog.csdn.net/u012702547/article/details/52461396)。 3. 约束布局(ConstraintLayout):约束布局是一种相对新的布局方式,它通过将组件之间的关系表示为约束来定位组件。这种布局方式在Android Studio中得到了很好的支持。你可以使用可视化编辑器轻松创建约束布局。详细教程请参考CSDN的[Android开发之约束布局详解](https://blog.csdn.net/u012702547/article/details/52580102)。 除了以上几种常用的布局方式,你还可以了解以下几个方面的内容来完善你的UI界面布局技能: - 使用嵌套布局:将多个布局嵌套在一起可以创建更复杂的UI界面。 - 使用自定义布局:Android允许你根据自己的需求创建自定义的布局。 - 使用列表布局:列表布局(如RecyclerView)是在Android开发中非常常见的一种布局方式,它可以用来展示大量的数据。 希望以上资源对你有所帮助!如果你还有其他问题,可以继续提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值