android studio 页面布局(1)

这篇具有很好参考价值的文章主要介绍了android studio 页面布局(1)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:orientation="vertical"
    tools:context=".MainActivity3">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="线性布局"
        android:gravity="center">
    </TextView>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="#00ffaa"
            android:text="横排第一个"
            android:gravity="center">

        </TextView>

        <TextView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="#00ff11"
            android:text="横排第二个"
            android:gravity="center">

        </TextView>

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

        <TextView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:background="#00aaaa"
            android:text="竖排第一个"
            android:gravity="center">

        </TextView>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:background="#00ff11"
            android:text="竖排第二个"
            android:gravity="center">

        </TextView>
    </LinearLayout>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="相对布局"
        android:gravity="center">
    </TextView>
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:background="#aa00aa">
        <TextView
            android:id="@+id/tv_centerHorizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#00ffaa"
            android:text="水平中间"
            android:layout_centerHorizontal="true">
        </TextView>
        <TextView
            android:id="@+id/tv_center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#00ffaa"
            android:text="相对布局"
            android:layout_centerInParent="true">
        </TextView>
        <TextView
            android:id="@+id/tv_centerVertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#00ffaa"
            android:text="垂直中间"
            android:layout_centerVertical="true">
        </TextView>

        <TextView
            android:id="@+id/tv_alignParentLeft"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#00ffaa"
            android:text="左上对齐"
            android:layout_alignParentLeft="true">
        </TextView>
        <TextView
            android:id="@+id/tv_alignParentRight"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#00ffaa"
            android:text="右上对齐"
            android:layout_alignParentRight="true">
        </TextView>
        <TextView
            android:id="@+id/tv_alignParentBottom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#00ffaa"
            android:text="底部对齐"
            android:layout_alignParentBottom="true">
        </TextView>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#00ff00"
            android:text="中间左边"
            android:layout_toLeftOf="@+id/tv_center"
            android:layout_alignBottom="@+id/tv_center"
            >
        </TextView>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#00ff00"
            android:text="中间右边"
            android:layout_toRightOf="@+id/tv_center"
            android:layout_alignBottom="@+id/tv_center"
            >
        </TextView>
        <TextView
            android:id="@+id/tv_rightBottom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#00ff00"
            android:text="底部右边"
            android:layout_alignRight="@+id/tv_alignParentRight"
            android:layout_alignBottom="@+id/tv_alignParentBottom"
            >
        </TextView>
        <TextView
            android:id="@+id/tv_centerBottom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#00ff00"
            android:text="中间下边"
            android:layout_alignRight="@+id/tv_center"
            android:layout_alignBottom="@+id/tv_alignParentBottom"
            >
        </TextView>
        <TextView
            android:id="@+id/tv_centerRight"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#00ff00"
            android:text="中间右边"
            android:layout_alignLeft="@id/tv_alignParentRight"
            android:layout_alignBottom="@id/tv_center"
            >
        </TextView>

    </RelativeLayout>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="网格布局"
        android:gravity="center">
    </TextView>
    <GridLayout
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:columnCount="2"
        android:rowCount="2">
        <TextView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_columnWeight="1"
            android:layout_rowWeight="1"
            android:text="粉色"
            android:background="#ffcccc"
            android:textColor="#000000"
            android:textSize="30sp"
            android:gravity="center">
        </TextView>
        <TextView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_columnWeight="1"
            android:layout_rowWeight="1"
            android:text="橙色"
            android:background="#ffaa00"
            android:textColor="#000000"
            android:textSize="30sp"
            android:gravity="center">
        </TextView>
        <TextView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_columnWeight="1"
            android:layout_rowWeight="1"
            android:text="绿色"
            android:background="#00ff00"
            android:textColor="#000000"
            android:textSize="30sp"
            android:gravity="center">
        </TextView>
        <TextView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_columnWeight="1"
            android:layout_rowWeight="1"
            android:text="紫色"
            android:background="#aa00aa"
            android:textColor="#000000"
            android:textSize="30sp"
            android:gravity="center">
        </TextView>
    </GridLayout>
    <Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
        android:text="下一页">
    </Button>

    <HorizontalScrollView
        android:layout_width="wrap_content"
        android:layout_height="100dp">
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="horizontal">
            <TextView
                android:layout_width="300dp"
                android:layout_height="match_parent"
                android:background="#ff00cc"
                android:text="水平滚动">

            </TextView>
            <TextView
                android:layout_width="300dp"
                android:layout_height="match_parent"
                android:background="#00ffaa">
            </TextView>
            <TextView
                android:layout_width="300dp"
                android:layout_height="match_parent"
                android:background="#cc66ff">
            </TextView>
        </LinearLayout>
    </HorizontalScrollView>
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="400dp"
                android:background="#ff00cc"
                android:text="垂直滚动">

            </TextView>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="400dp"
                android:background="#00ffaa">
            </TextView>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="400dp"
                android:background="#cc66ff">
            </TextView>
        </LinearLayout>
    </ScrollView>

</LinearLayout>

android studio 页面布局(1)文章来源地址https://www.toymoban.com/news/detail-423041.html

到了这里,关于android studio 页面布局(1)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Android studio报错:Plugin [id: ‘com.android.application‘, version: ‘7.2.0‘

    之前我是在笔记本电脑上安装的Android studio,是能使用的好好的,但是这次在新台式电脑上安装Android studio之后新建project发现报错:Plugin [id: \\\'com.android.application\\\', version: \\\'7.2.0\\\', apply: false] was not found in any of the following sources 1、试过将Android studio文件Gradle Script下面的gradle-wrapper.

    2024年02月17日
    浏览(31)
  • Android Studio开发学习(五)———LinearLayout(线性布局)

            认识了解一下Android中的布局,分别是: LinearLayout(线性布局),RelativeLayout(相对布局),TableLayout(表格布局), FrameLayout(帧布局),AbsoluteLayout(绝对布局),GridLayout(网格布局) 等。 1.常见属性 (1)id值: android:id=\\\"@+id/\\\"         id相当于一个标识,方便后期写代码时找

    2024年04月13日
    浏览(25)
  • android studio使用Flutter Inspector调试布局

    1、点击anroid studio右侧的Flutter Inspector按钮 2、点击展开布局右上角的‘Select Widget  Mode’,即可实现点击相关节点,真机上可以看到相关的方框 如下图  

    2024年02月13日
    浏览(30)
  • Android Studio学习一得——Android用户界面的设计布局

    当我们创建了一个安卓项目后,我们会发现真正建立一个完善的安卓项目并不是想象的那么容易。其实和设计可视化界面一样,开发安卓也需要考虑很多方面,主要考虑的还是界面布局和需要的组件。 Android系统按照 MVC ( 模型(model) - 视图(view) - 控制器(controller) )设计模式将应

    2024年02月09日
    浏览(36)
  • 学会使用Android Studio网格布局制作计算器界面

    1.1GridLayout布局使用虚细线将布局划分为行、列和单元格,也支持一个控件在行、列上都有交错排列。 1.2可以自己设置布局中组件的排列方式 1.3可以自定义网格布局有多少行、多少列 1.4可以直接设置组件位于某行某列 1.5可以设置组件横跨几行或者几列 基于-  Empty Activity 模板

    2024年02月08日
    浏览(38)
  • Android Studio中布局文件.xml不出现代码提示

    所遇问题:如图所示(学习Android中发现写布局文件代码时没有代码提示) 我的解决方法:查看很多博主写的方法,然后试了很多方法,然后找到了适合自己的方法。   1.首先左上角点击File-----找到Project Stucture----Modules-----找到右边没有出现代码的模块(例如我的是chapter2_li

    2024年04月28日
    浏览(28)
  • Android Studio 布局无法预览解决方案,亲测有效

    有人说是因为主题导致的。其实有部分是因为主题,在原来的主题parent的前面加一个Base,变成Base.Theme.Light等。但是大多数是无法解决的。 但是在出现initializing或者loading是无法解决,最好的办法就是删除 项目的配置信息和gradle的配置文件。因为idea和gradle如果出现异常就到导

    2023年04月25日
    浏览(43)
  • Android studio 报错 Plugin [id: ‘com.android.application‘, version: ‘8.1.0‘, apply: false]

    之前的项目可以运行,过一阵再次打开发现报错如下。但是新建Android studio 项目没有问题可以运行。 很久没有查到原因缺的version: \\\'8.1.0\\\'之前已经下载过也不知道为啥还要提示下载 然后就是下载失败 问题后来问题解决 将上边路径修改如下 点击🆗 等待下载完成问题解决

    2024年02月03日
    浏览(42)
  • Android studio下的线性布局(LinearLayout)与水平布局(ReativeLayout)详细解析+典型例子及其代码

    一:线性布局 线性布局有水平线性布局: android :orientation =\\\"horizontal\\\" ; 和垂直线性布局: android :orientation =\\\"vertical\\\" 两种布局。 当代码表示 android :orientation =\\\"horizontal\\\" 时, 表示这个布局下的所有子元素都要水平方向排列。 当代码表示 android :orientation =\\\"verticall\\\" 时, 表示这个布

    2024年02月09日
    浏览(37)
  • Android Studio入门之常用布局的讲解以及实战(附源码 超详细必看)(包括线性布局、权重布局、相对布局、网格布局、滚动视图 )

    运行有问题或需要源码请点赞关注收藏后评论区留言 顾名思义,线性布局像是用一根线把它的内部视图串起来,故而内部视图之间的排列顺序是固定的,要么从左到右,要么从上到下排列。通过属性android:orientation区分两种方向 下面通过一个实例讲解 效果如下  activity_linea

    2023年04月20日
    浏览(39)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包