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属性设置两个值. 注意属性值和|之间不能有空格空开

  • 相关阅读:
    sublime打开txt文件乱码的问题
    while循环小例
    mongoDB内置文档定义
    WebStorm 10.0.3注册码
    angularjs之ng-mode获取lobject类型里的键值
    前端打印console
    js去掉数组的空字符串
    js数组去重的三种方式的比较
    js数据类型之判断
    Bootstrap中的datetimepicker浅谈
  • 原文地址:https://www.cnblogs.com/huangZ-H/p/10643364.html
Copyright © 2011-2022 走看看