zoukankan      html  css  js  c++  java
  • 安卓课本例子-01-使用XML布局文件控制用户界面

    看了几集B站的安卓的入门视频, 觉得已经可以看懂安卓的代码了, 而且运行环境也搭建完成了, 可以脱离视频, 通过文字来进行更加高效的学习了.

    https://www.bilibili.com/video/av22836860/?p=21


     使用XML控制UI布局:

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3     xmlns:app="http://schemas.android.com/apk/res-auto"
     4     xmlns:tools="http://schemas.android.com/tools"
     5     android:layout_width="match_parent"
     6     android:layout_height="match_parent"
     7     tools:context=".MainActivity">
     8 
     9     <TextView
    10         android:layout_width="wrap_content"
    11         android:layout_height="wrap_content"
    12         android:id="@+id/text1"
    13         android:text="@string/title"
    14         app:layout_constraintBottom_toBottomOf="parent"
    15         app:layout_constraintLeft_toLeftOf="parent"
    16         app:layout_constraintRight_toRightOf="parent"
    17         app:layout_constraintTop_toTopOf="parent" />
    18 
    19     <TextView
    20         android:layout_width="wrap_content"
    21         android:layout_height="wrap_content"
    22         android:id="@+id/text2"
    23         android:text="@string/start"
    24         android:layout_gravity="center_horizontal|center_vertical"
    25         app:layout_constraintBottom_toBottomOf="parent"
    26         app:layout_constraintLeft_toLeftOf="parent"
    27         app:layout_constraintRight_toRightOf="parent"
    28         app:layout_constraintTop_toTopOf="parent" />
    29 
    30 </FrameLayout>

    注意第24行, 中间使用了‘|’符号, 表示“或”运算, 功能是同时给android:layout_gravity属性设置两个值. 注意属性值和|之间不能有空格空开

  • 相关阅读:
    Bootstrap(6)图标菜单按钮组件
    Bootstrap(6)辅组类和响应式工具
    Bootstrap(5)栅格系统
    Bootstrap(4) 表单和图片
    Bootstrap(3) 表格与按钮
    Bootstrap(2) 排版样式
    Bootstrap(1) 概述与环境搭建
    requirejs简单应用
    Validate常用校验
    VSS2005源代码管理启用http方式
  • 原文地址:https://www.cnblogs.com/huangZ-H/p/10643364.html
Copyright © 2011-2022 走看看