Android布局-ConstraintLayout
一. 简介首先,和其他的布局一样,ConstraintLayout 和其它的 布局 一样是继承于 ViewGroup。它的出现主要是为了解决布局嵌套过多的问题,以灵活的方式定位和调整 View。学过 iOS开发 的小伙伴肯定都知道在xib或者storyboard里面的拖拽布局或者说约束布局,和我们这里的很像,但其实还是有很大的区别的。
ConstraintLayout 和其他的布局一样有以下这些的属性:
① View在左上右下四个方向和其他View之间的距离,值是 dp
1234android:layout_marginStart (android:layout_marginLeft) android:layout_marginTopandroid:layout_marginEnd (android:layout_marginRight)android:layout_marginBottom
② View内部元素到View左上右下边框之间的距离,值是 dp
1234android:paddingStart (android:paddingLeft)android:paddingT ...
Android布局-GridLayout
一. 简介GridLayout网格布局是在Android 4.0以后引入的一种新的布局模式,和表格布局是有点类似的,但比表格布局的好,功能也是很强大的,它可以设置布局有多少行和有多少列,也可以设置布局中的组件的排列方式,也可以设置组件的位置,横跨多少行,多少列。
二. Xml方式1. 所有的布局共有的属性① View在左上右下四个方向和其他View之间的距离,值是 dp
1234android:layout_marginStart (android:layout_marginLeft) android:layout_marginTopandroid:layout_marginEnd (android:layout_marginRight)android:layout_marginBottom
② View内部元素到View左上右下边框之间的距离,值是 dp
1234android:paddingStart (android:paddingLeft)android:paddingTopandroid:paddingEnd (android:paddingRight)androi ...
Android布局-TableLayout
一. 简介TableLayout是将子类向分别排列成行和列的布局视图容器,TableLayout是由许多TableRow对象组成的,表格布局以行列的形式管理子控件,每一个单元是一个TableRow或者View对象。
在TableLayout中可以通过setConlumnShrinkable()或setConlumnStretchable()方法来指定某些列为可以缩小或可伸缩,列是从0开始计数的,第一列为0。
二. Xml方式1. 所有的布局共有的属性① View在左上右下四个方向和其他View之间的距离,值是 dp
1234android:layout_marginStart (android:layout_marginLeft) android:layout_marginTopandroid:layout_marginEnd (android:layout_marginRight)android:layout_marginBottom
② View内部元素到View左上右下边框之间的距离,值是 dp
1234android:paddingStart (android:paddi ...
Android布局-AbsoluteLayout
一. 简介AbsoluteLayout(绝对布局),是因为绝对布局,我们基本上都是不会使用的,但是我们还是可以了解这个AbsoluteLayout布局的。放入该布局的UI控件通过 android:layout_x 和 android:layout_y 两个属性指定其准确的坐标值,并显示在屏幕上。
理论上,AbsoluteLayout布局可用以完成任何的布局设计,灵活性很大,但是在实际的工程应用中不提倡使用这种布局。因为使用这种布局不但需要精确计算每个组件的大小,增大运算量,而且当应用程序在不同屏幕尺寸的手机上运行时会产生不同效果。
二. Xml方式1. 所有的布局共有的属性① View在左上右下四个方向和其他View之间的距离,值是 dp
1234android:layout_marginStart (android:layout_marginLeft) android:layout_marginTopandroid:layout_marginEnd (android:layout_marginRight)android:layout_marginBottom
② View内部元 ...
Android布局-FrameLayout
一. 继承图
二. Xml方式1. 所有的布局共有的属性① View在左上右下四个方向和其他View之间的距离,值是 dp
1234android:layout_marginStart (android:layout_marginLeft) android:layout_marginTopandroid:layout_marginEnd (android:layout_marginRight)android:layout_marginBottom
② View内部元素到View左上右下边框之间的距离,值是 dp
1234android:paddingStart (android:paddingLeft)android:paddingTopandroid:paddingEnd (android:paddingRight)android:paddingBottom
③ 容器 内部的对齐方式 以及 容器相对于父容器的对齐方式
12android:gravity //设置布局管理器内组件的对齐方式android:layout_gravity //设置布局本身相对于父 ...
Android布局-彻底搞懂Android布局中的layout_weight
一. 先看下面的布局
12345678910111213141516171819202122232425262728293031323334353637<?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" tools:context=".FirstActivity" and ...
Android控件-ScrollView & HorizontalScrollView
一. 继承图
ScrollView称为滚动视图,当在一个屏幕的像素显示不下绘制的UI控件时,可以采用滑动的方式,使控件显示。
从继承图可以看出,ScrollView原来是一个FrameLayout的容器,不过在他的基础上添加了滚动,允许显示的比实际多的内容。
二. ScrollView1.首先,我们在一个垂直排列的 LinearLayout 的 放置五个按钮,我们会发现由于超出屏幕的显示范围,我们看不到下面部分的按钮。
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.and ...
Android项目:环菜单动画
一. 运行效果以及源码1.gif图效果
2.源码地址环菜单动画
二. 主要的思路1. 界面布局三个圆环直接用三个 RelativeLayout 摆放,只需要将三个 RelativeLayout 的背景设置为三个圆环即可。
每个圆环的小菜单的倾斜程度无需考虑,其图片资源本身就有倾斜程度。
2. 如何优雅的设置第三层菜单随着第二层菜单旋转而旋转抽出一个方法 close(View view, long delay),对不同的层级设置不同的动画延迟时间即可。