首页 > 其他分享 >3月8号Android开发学习

3月8号Android开发学习

时间:2023-03-11 11:14:07浏览次数:37  
标签:滚动 网格 视图 学习 开发 下级 layout Android 属性

相对布局RelativeLayout

相对布局的下级视图由其他视图决定,用于确定下级视图位置的参照物分两种:

(1)与该视图自身平级的视图

(2)该视图的上级视图

如果不设定下级视图的参照物,那么下级视图默认显示在RelativeLayout内部的左上角

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="150dp"
    >

    <TextView
        android:id="@+id/tv_center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="#ffffff"
        android:text="我在中间"
        android:textColor="#000000"
        android:textSize="11sp"></TextView>
    <TextView
        android:id="@+id/tv_center_Horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:background="#ffffff"
        android:text="我在水平中间"
        android:textColor="#000000"
        android:textSize="11sp"></TextView>
    <TextView
        android:id="@+id/tv_center_vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:background="#ffffff"
        android:text="我在垂直中间"
        android:textColor="#000000"
        android:textSize="11sp"></TextView>
    <TextView
        android:id="@+id/tv_align_parent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:background="#ffffff"
        android:text="我在上级的左边对齐"
        android:textColor="#000000"
        android:textSize="11sp"></TextView>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:background="#ffffff"
        android:text="我在上级的右边对齐"
        android:textColor="#000000"
        android:textSize="11sp"></TextView>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="#ffffff"
        android:text="我在上级的地部对齐"
        android:textColor="#000000"
        android:textSize="11sp"></TextView>
    


</RelativeLayout>

 网格布局GridLayout

网格布局支持多行多列的表格排列

网格布局默认从左往右,从上到下排列,它新增了两个属性:

columnCout属性,指定网格的列数

rowCount属性,指定网格的行数

滚动视图ScrollView

滚动视图有两种:

Scrollview,它是水平方向的滚动视图,垂直方向滚动时,layout_width属性值设置为match_parent,layout_height属性值设置为wrap_content

HorientationScorllView,它是水平方向的滚动视图,水平方向滚动时,layout_width属性值设置为wrap_content,layout_height属性值设置为match_parent

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


    <HorizontalScrollView
        android:layout_width="wrap_content"
        android:layout_height="200dp">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="horizontal">

            <View
                android:layout_width="300dp"
                android:layout_height="match_parent"
                android:background="#DA5D5D"></View>
            <View
                android:layout_width="300dp"
                android:layout_height="match_parent"
                android:background="#3C9FCC"></View>
        </LinearLayout>
    </HorizontalScrollView>
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <View
                android:layout_width="match_parent"
                android:layout_height="400dp"
                android:background="#D586E3"></View>

            <View
                android:layout_width="match_parent"
                android:layout_height="400dp"
                android:background="#72EC77"></View>
        </LinearLayout>
    </ScrollView>

</LinearLayout>

 

标签:滚动,网格,视图,学习,开发,下级,layout,Android,属性
From: https://www.cnblogs.com/cinan/p/17205375.html

相关文章

  • odoo ORM API学习总结兼orm学习教程
    环境odoo-14.0.post20221212.tarORMAPI学习总结/学习教程模型(Model)Model字段被定义为model自身的属性fromodooimportmodels,fieldsclassAModel(models.Model......
  • 实验1 Python开发环境使用和编程初体验
    实验任务1 task1_1print('hey','u')x,y,z=1,2,3print(x,y,z)print('x=%d,y=%d,z=%d'%(x,y,z))print('x={},y={},z={}'.format(x,y,z))print('x=%d,y......
  • 操作系统学习笔记2-进程和线程
    2.进程和线程2.0引入2.0.1顺序执行特征顺序性封闭性:独占整机资源可再现性:只要在相同的环境与初始条件下,执行结果相同顺序执行的场合:单道批处理系统2.0.2并......
  • 机器学习算法之有监督学习和无监督学习的区别
    如今机器学习和人工智能是大家耳熟能详的两个词汇,在我们日常生活中也是被高频的提到。其实机器学习只是人工智能的一部分,是人工智能的一个子集,它往往是通过示例和经验模型......
  • VScode开发者工具快捷键
    VScode开发者工具快捷键 VSCode打开文件夹与创建文件选择文件夹拖拽文件夹生成浏览器文件.html的快捷方式!+回车VSCode常用快捷键列表代码格式化:Sh......
  • edge扩展开发-页面间的通信
    1.popup.html<!DOCTYPEhtml><html><head><metahttp-equiv="content-type"content="text/html;charset=utf-8"><metaname="viewport"conten......
  • 实验1 Python开发环境使用和编程初体验
    实验任务1_1实验源码1#print输出的几种用法23#用法1:输出单个字符串或变量4print('heyyou')56#用法2:输出多个数据项,用逗号分隔7print('hey,u')......
  • 3.10学习总结
    条件语句publicclassTest{publicstaticvoidmain(Stringargs[]){intx=10;if(x<20){System.out.print("这是if语句");}}}publicclassTest{publ......
  • m基于深度学习的OFDM信道估计和均衡算法误码率matlab仿真,对比了LS,MMSE以及LMMSE等传
    1.算法描述      随着无线通信的快速发展,5G正逐渐成长为支撑全社会各行业运作的大型基础性互联网络,其服务范围的大幅扩展对底层技术提出了诸多挑战,尤其是作为物......
  • Android源码下载
      最近在做Monkey二次开发的工作,边弄边在这里记录下(多平台发布),顺便可以和大家一起讨论下; Monkey的编译依赖于Android源码,所以要修改Monkey后打新jar包,需要完整的Andr......