当前位置: 首页 > wzjs >正文

网站单个页面做301网络营销的目的和意义

网站单个页面做301,网络营销的目的和意义,wordpress用微信登录,wordpress装机主题这一节主要了解一下Compose中多点触控,在Jetpack Compose 中,多点触控处理需要结合Modifier和手势API来实现,一般通过组合 pointerInput、TransformableState 和 TransformModifier 来创建支持缩放、旋转和平移的组件。 一、 API 1. Pointer…

         这一节主要了解一下Compose中多点触控,在Jetpack Compose 中,多点触控处理需要结合Modifier和手势API来实现,一般通过组合 pointerInput、TransformableState 和 TransformModifier 来创建支持缩放、旋转和平移的组件。

一、 API
1. PointerInput
含义:处理低级触摸事件的主要API,支持多点触控。
用法:通过pointerInput修饰符拦截和处理触摸事件。
2. TransformableState
含义:管理变换状态(缩放、旋转、平移)的状态容器。
用法:与transformable修饰符结合,监听手势并更新变换值。
3. TransformModifier
含义:应用变换效果(缩放、旋转、平移)的修饰符。
用法:通过graphicsLayer或transformable应用变换。
二、关键类与接口
1. PointerInputScope
提供处理触摸事件的作用域,包含:
detectDragGestures:处理单指拖拽。
detectTransformGestures:处理双指缩放 / 旋转。
detectTapGestures:处理点击事件。
2. TransformScope
在detectTransformGestures中提供:
panChange:平移变化量。
zoomChange:缩放变化量。
rotationChange:旋转变化量。
3. Transformation
包含三个变换参数:
scale:缩放因子。
rotation:旋转角度。
offset:平移偏移量。

栗子:

1. 单指拖拽

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.input.pointer.consumeAllChanges
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.example.composenavigationdemo.R@Composable
fun TestImage() {var offset by remember { mutableStateOf(Offset.Zero) }Box(modifier = Modifier.size(200.dp).background(Color.LightGray).pointerInput(Unit) {detectDragGestures { change, dragAmount ->// 阻止事件冒泡change.consumeAllChanges()// 更新偏移量offset = offset + dragAmount}}.graphicsLayer {translationX = offset.xtranslationY = offset.y}) {Image(painter = painterResource(R.drawable.android),contentDescription = null,modifier = Modifier.fillMaxSize())}
}

2. 双指缩放与旋转

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.detectTransformGestures
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.res.painterResource
import com.example.composenavigationdemo.R@Composable
fun TestImage() {var scale by remember { mutableStateOf(1f) }var rotation by remember { mutableStateOf(0f) }var offset by remember { mutableStateOf(Offset.Zero) }Box(modifier = Modifier.fillMaxSize().background(Color.LightGray).pointerInput(Unit) {detectTransformGestures { centroid, pan, zoom, rotationChange ->// 更新变换参数scale = (scale * zoom).coerceIn(0.5f, 5f)rotation += rotationChangeoffset = centroid}}) {Image(painter = painterResource(R.drawable.android),contentDescription = null,modifier = Modifier.align(Alignment.Center).graphicsLayer {scaleX = scalescaleY = scalerotationZ = rotationtranslationX = offset.x - size.width / 2translationY = offset.y - size.height / 2})}
}

3 组合多种手势

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.gestures.detectTransformGestures
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.res.painterResource
import com.example.composenavigationdemo.R
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch@Composable
fun TestImage() {var scale by remember { mutableStateOf(1f) }var rotation by remember { mutableStateOf(0f) }var offset by remember { mutableStateOf(Offset.Zero) }var isDragging by remember { mutableStateOf(false) }Box(modifier = Modifier.fillMaxSize().background(Color.LightGray).pointerInput(Unit) {coroutineScope {launch {detectDragGestures(onDragStart = { isDragging = true },onDragEnd = { isDragging = false }) { change, dragAmount ->offset += dragAmount}}launch {detectTransformGestures(panZoomLock = true) { _, pan, zoom, rotationChange ->scale *= zoomrotation += rotationChangeoffset += pan}}}}.graphicsLayer {scaleX = scalescaleY = scalerotationZ = rotationtranslationX = offset.xtranslationY = offset.y}) {Image(painter = painterResource(R.drawable.android),contentDescription = null,modifier = Modifier.align(Alignment.Center))}
}

注意:
1 事件消费:通过change.consumeAllChanges()阻止事件冒泡。
2 坐标系转换:注意centroid(双指中心点)和offset的坐标系差异。
3 状态管理:使用remember保存变换状态,确保配置变更后状态恢复。

http://www.dtcms.com/wzjs/294335.html

相关文章:

  • 做网站的图片取材百度应用商店官网
  • 智慧政府门户网站建设方案常用网站推广方法及资源
  • python做网站性能怎么样真正免费的网站建站
  • 苏州园区做网站公关公司提供的服务有哪些
  • 上海公安门户网站网址是多少西安百度推广客服电话多少
  • 网站项目设计流程案例宁波seo推广如何收费
  • 北京卓天下网站建设公司怎样自己制作网站
  • 做网站标准步骤2023年第三波疫情9月
  • 长沙建设信息网站色盲悖论
  • php asp jsp 网站今日新闻大事件
  • 南充房管局网站查询房产广州疫情今天最新消息
  • wordpress精品插件seo公司 上海
  • 举报网站赚钱seo整站优化外包公司
  • 怎么用WordPress快速建站网页制作教程书籍
  • dns 部分网站打不开淘宝关键词搜索量排名
  • 用j2ee作的网站seo查询seo
  • 专做运动品牌的网站首页关键词排名代发
  • 学做视频的网站有哪些内容网页优化seo公司
  • 建立网站的价格营销培训方案
  • 自考本科报名入口官网seo关键词排名优化制作
  • 深圳网站优化服务旅游推广赚佣金哪个平台好
  • 做网站公司郑州网页设计主要做什么
  • 启东市住房建设局网站如何建立个人网址
  • 成交型网站建设南京百度快照优化排名
  • 做图的软件网站山东服务好的seo公司
  • b2c网站建设哪家好搜狗输入法下载安装
  • 网站的推广费用小红书推广方式有哪些
  • 北京网站建设哪家比较好培训班报名
  • 盗用别人的图片做网站犯法公司以优化为理由裁员合法吗
  • 签订网站制作合同注意事项抖音搜索seo排名优化