Android_View
文章平均质量分 59
Android开发不知道不行的内容
怪叔叔萝莉控
学一门新技术,要放下姿态,从零开始
展开
-
七、如何区分点击与滑动
Touch事件与TouchSlop前置知识:坐标系统知识package com.ifredomer.touchandclickimport android.annotation.SuppressLintimport androidx.appcompat.app.AppCompatActivityimport android.os.Bundleimport android.view.MotionEventimport android.view.ViewConfigurationimport原创 2021-11-30 21:20:19 · 2388 阅读 · 0 评论 -
六、View的坐标系统
View的事件体系View的坐标系统从Android3.0开始,View增加了额外的几个参数:x、y :其中x和y是View左上角的坐标translationX、translationY : translationX和translationY是View左上角相对于父容器的偏移量。translationX和translationY的默认值是0View的四个基本的位置(left、right、buttom、top)参数一样,View也为它们提供了get/set方法,这几个参数的换算关系如下所示。原创 2021-11-30 09:04:00 · 1964 阅读 · 0 评论 -
五、INVISIBLE、GONE、VISIBLE的实现逻辑
INVISIBLE、GONE、VISIBLE这三个变量,应该是我们最常用的了,有没有思考系统是怎么实现的呢?ViewGroup首先要明确一点,通常使用的View都是放在ViewGroup以及其子类的。大小都是在父控件的onMeasure和onLayout来进行确定...原创 2021-01-31 19:56:47 · 3169 阅读 · 3 评论 -
四、增加横向逻辑
上一章我们已经增加了指定方向的attr.接下来,接下来我们来看一下,怎么横向测量和布局。先晒一下我们的xml <com.jhzl.customview.MineLineLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:background="@原创 2021-01-28 22:07:37 · 117 阅读 · 0 评论 -
三、自定义attr属性,指定方向
LinearLayout的orientationorientation是支持横向和竖向的,且是直接写在布局里面的,那么我们自定义的话是怎么来实现呢?这里就要延伸出一个自定义属性的东西。使用步骤在attr.xml里面配置<?xml version="1.0" encoding="utf-8"?><resources> <declare-styleable name="MineLineLayout"> <attr name="andro原创 2021-01-28 19:53:36 · 445 阅读 · 1 评论 -
一、自定义一个竖直Layout
垂直Layout我们想到的第一直觉肯定是ViewGroup,自定义一个ViewGroup通常包含onMeasure(测量),onLayout(布局)。onMeasureonMeasure是一个父往子依次measure的过程。当我们要画一个竖直的Layout.我们应该得到下图:父控件的高度是子控件的高度和。设自定义viewgroup有三个EditText<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android原创 2020-12-18 21:18:26 · 261 阅读 · 0 评论 -
二、自定义垂直ViewGroup如何设置margin
ViewGroup设置margin累计分为三步:1.获取margin2.onMeasure里面加上margin3.onLayout布局设置margin获取margin首先呢,ViewGroup是自带的MarginLayoutParams的,但是在addView时,查看源码: public void addView(View child, int index) { if (child == null) { throw new IllegalArgu.原创 2020-12-19 06:01:45 · 1028 阅读 · 1 评论