前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >线性布局LinearLayout(二)小练习

线性布局LinearLayout(二)小练习

作者头像
李小白是一只喵
发布2020-04-24 08:46:28
5370
发布2020-04-24 08:46:28
举报
文章被收录于专栏:算法微时光

image.png

目录

七色板

使用线性布局构建七色板,首先查看下配色表,这其中颜色的编码是多少:

颜色

编码

android:background="#FF0033"

android:background="#FFCC33"

android:background="#FFFF00"

绿

android:background="#00CC00"

android:background="#0066CC"

android:background="#6666CC"

android:background="#993399"

activity_main.xml文件里主要为:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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=".MainActivity">

    <LinearLayout
        android:id="@+id/linearLayout11"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">


    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="match_parent"
        android:layout_height="75dp"
        android:background="#FF0033"></LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="match_parent"
        android:layout_height="75dp"
        android:background="#FFCC33"></LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout3"
        android:layout_width="match_parent"
        android:layout_height="75dp"
        android:background="#FFFF00"></LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout4"
        android:layout_width="match_parent"
        android:layout_height="75dp"
        android:background="#00CC00"></LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout5"
        android:layout_width="match_parent"
        android:layout_height="75dp"
        android:background="#0066CC"></LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout6"
        android:layout_width="match_parent"
        android:layout_height="75dp"
        android:background="#6666CC"></LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout7"
        android:layout_width="match_parent"
        android:layout_height="75dp"
        android:background="#993399"></LinearLayout>
    </LinearLayout>

</android.support.constraint.ConstraintLayout>

解析

代码语言:javascript
复制
 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"

xmlns:android和xmlns:tools指定的是xml文件的命名空间,不是对布局的主要设置.

代码语言:javascript
复制
 android:layout_width="match_parent"

用于指定当前的线性布局宽度占整个父元素,这里相对于当前的线性布局父元素为当前的窗体,所以宽度占满窗体

代码语言:javascript
复制
android:layout_height="match_parent"

用于指定当前的线性布局高度占整个父元素,这里相对于当前的线性布局父元素为当前的窗体,所以高度占满窗体

代码语言:javascript
复制
tools:context="com.example.activitylife.MainActivity"

用于指定渲染上下文

代码语言:javascript
复制
android:orientation="vertical"

用于指定当前控件为垂直摆放

代码语言:javascript
复制
android:background="#993399"

用于指定背景色

生成的效果

image.png

虚拟机运行结果

image.png

好了打完收工,回去睡觉.O(∩_∩)O

参考

Android的学习第六章(布局一LinearLayout) 网页设计常用色彩搭配表 《配色表》

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 目录
  • 七色板
  • 解析
    • 生成的效果
    • 虚拟机运行结果
    • 参考
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档