首页 > 其他分享 >2022-10-10学习内容

2022-10-10学习内容

时间:2022-10-10 21:55:06浏览次数:41  
标签:xml 10 效果 3.1 学习 2022 activity

1.RelativeLayout

1.1activity_relative_layout.xml

<?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
        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
        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
        android:id="@+id/tv_parent_left"
        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
        android:id="@+id/tv_parent_right"
        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
        android:id="@+id/tv_parent_top"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:background="#ffffff"
        android:text="我跟上级顶部对齐"
        android:textColor="#000000"
        android:textSize="11sp" />

    <TextView
        android:id="@+id/tv_parent_bottom"
        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
        android:id="@+id/tv_left_center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@id/tv_center"
        android:layout_alignTop="@id/tv_center"
        android:background="#ffffff"
        android:text="我在中间左边"
        android:textColor="#000000"
        android:textSize="11sp" />

    <TextView
        android:id="@+id/tv_right_center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/tv_center"
        android:layout_alignBottom="@id/tv_center"
        android:background="#ffffff"
        android:text="我在中间右边"
        android:textColor="#000000"
        android:textSize="11sp" />

    <TextView
        android:id="@+id/tv_above_center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/tv_center"
        android:layout_alignLeft="@id/tv_center"
        android:background="#ffffff"
        android:text="我在中间上面"
        android:textColor="#000000"
        android:textSize="11sp" />

    <TextView
        android:id="@+id/tv_below_center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/tv_center"
        android:layout_alignRight="@id/tv_center"
        android:background="#ffffff"
        android:text="我在中间下面"
        android:textColor="#000000"
        android:textSize="11sp" />

</RelativeLayout>

1.2效果

 

 2.GridLayout

2.1activity_grid_activity.xml

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:columnCount="2"
    android:rowCount="2">

    <TextView
        android:layout_width="0dp"
        android:layout_columnWeight="1"
        android:layout_height="60dp"
        android:background="#ffcccc"
        android:gravity="center"
        android:text="粉红色"
        android:textColor="#000000"
        android:textSize="17sp" />

    <TextView
        android:layout_width="0dp"
        android:layout_columnWeight="1"
        android:layout_height="60dp"
        android:background="#ffaa00"
        android:gravity="center"
        android:text="橙色"
        android:textColor="#000000"
        android:textSize="17sp" />

    <TextView
        android:layout_width="0dp"
        android:layout_columnWeight="1"
        android:layout_height="60dp"
        android:background="#00ff00"
        android:gravity="center"
        android:text="绿色"
        android:textColor="#000000"
        android:textSize="17sp" />

    <TextView
        android:layout_width="0dp"
        android:layout_column qWeight="1"
        android:layout_height="60dp"
        android:background="#660066"
        android:gravity="center"
        android:text="深紫色"
        android:textColor="#000000"
        android:textSize="17sp" />

</GridLayout>

2.2效果

3.ScollView

3.1activity_scoll_view.xml

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

    <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="#aaffff" />

            <View
                android:layout_width="300dp"
                android:layout_height="match_parent"
                android:background="#ffff00" />

        </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="#00ff00" />

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

        </LinearLayout>

    </ScrollView>

</LinearLayout>

3.2效果

 

标签:xml,10,效果,3.1,学习,2022,activity
From: https://www.cnblogs.com/pingfanliliang/p/16774333.html

相关文章

  • PyTorch学习笔记
    #########################################################有关PyTorch一些学习笔记,目前笔记并不全面,只是针对性记录一些对应地铁预测中运用的的原理,函数,方法(有些没有使......
  • JDBC学习
    title:JDBC学习excerpt:tags:[Java,MySQL]categories:[学习,Java][学习,MySQL]index_img:https://picture-store-repository.oss-cn-hangzhou.aliyuncs.com/......
  • 2022NOIPA层联测6
    设密码比较失败,所以,A.构造字符串(str)并查集维护一下相同的位置,注意到$LCP+1$位置不同,于是每个集合取出来最靠前的为代表,两个集合不同,大集合向小集合连边,每次集合复......
  • #yyds干货盘点#【愚公系列】2022年10月 微信小程序-全局配置属性之页面配置
    前言微信小程序是由一个个单页面组成,每个页面都是由固定规则的。小程序页面自身分为两个主要部分独立运行:view模块和service模块。在开发者工具中,它们独立运行于不同的......
  • HTML学习
    title:HTML学习excerpt:重塑!tags:[狂神,HTML,表单]categories:[学习,网站运维]index_img:https://picture-store-repository.oss-cn-hangzhou.aliyuncs.com/......
  • 10 我可以不用发论文了?
    博客配套视频链接:https://www.bilibili.com/video/BV11g41127Zn/?spm_id_from=333.788&vd_source=b1ce52b6eb3a9e6c2360a4b7172edf5ab站直接看视频描述图片描述0:30......
  • Python 应用之求 100 以内的奇数和
    在数学中,我们需要用到很多求和的办法,比如说求1至100的和,还有100以内的所有偶数和和所有奇数和,如果我们慢慢地计算是不是很浪费时间,还容易出错。其实通过Python就可......
  • 【闲话】2022.10.10
    真的帮我妈登上了cnblogs好诶!今天Accoders考试T3T4真的不想改了除非我学到那一部分然后干了干李超树我完全明白了(不是继续搜索终于知道A*的用法了我好菜......
  • 20221005(补
    20221005题目简单点朴素算法​ 很容易想到存下每个位置后离它最近的各个字母的位置。然后再暴力地从答案区间\([l,r]\)的离左端点最近的\(e\)开始按\(e,a,s,y\)的顺序......
  • P1077 [NOIP2012 普及组] 摆花
    P1077首先二维数组的DP比较好想,设f(i,j)表示前i种花摆了j盆的方案数,方程为\(f(i,j)=\sum_{k=0}^{a[i]}f(i-1,j-k)\)代码如下:#include<bits/stdc++.h>usingn......