当前位置:网站首页>“山东大学移动互联网开发技术教学网站建设”项目实训日志三
“山东大学移动互联网开发技术教学网站建设”项目实训日志三
2022-07-29 05:19:00 【BEER_7】
时间:
21春季学期第六周
个人工作内容:
完成指南针案例app
全部视觉稿的组件和配色导出
详细记录:
- 指南针案例app设计说明
- 目标用户:android开发入门阶段的学生。
- 需求说明:说明传感器的使用方法,动画使用简单教学
- 设计说明:用一个指针盘表示朝向北的指针,传感器获取偏离角度后使得指针盘旋转并标出偏差角度,接近北方后字体变红以强调方位正确性
要点说明
- 指南针页面

xml文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center"
android:background="#211E1E">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NORTH"
android:textColor="#FFFFFF"
android:textSize="50sp" />
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/compass3"
android:layout_marginTop="60dp"/>
<TextView
android:id="@+id/degree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0°"
android:textColor="#FFFFFF"
android:textSize="50sp"
android:layout_marginTop="60dp"/>
</LinearLayout>
- 当接近北方时,角度指示会变红,在传感器监测方向改变的方法中判断度数即可实现

SensorListener内部类:
//通过getSystemService获得SensorManager实例对象
manager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
private final class SensorListener implements SensorEventListener {
private float predegree = 0;
//传感器监测方向改变
public void onSensorChanged(SensorEvent event) {
float degree = event.values[0];// 存放了方向值 90
动画,在上传感器监测方向改变的方法中写:
RotateAnimation animation = new RotateAnimation(predegree, -degree,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
//旋转过程持续时间
animation.setDuration(200);
//罗盘图片使用旋转动画
imageView.startAnimation(animation);
predegree = -degree;
后期工作规划:
- 下周完成摇摇闹钟案例App的开发和教学设计
边栏推荐
- Hcia-r & s self use notes (25) NAT technical background, NAT type and configuration
- [typescript] type reduction (including type protection) and type predicate in typescript
- 新手入门:手把手从PHP环境到ThinkPHP6框架下载
- 365 day challenge leetcode1000 question - day 036 binary tree pruning + subarray and sorted interval sum + delete the shortest subarray to order the remaining arrays
- Display effect of uniapp page title
- dcat 批量操作弹窗及参数传递
- JDBC连接数据库详细步骤
- 第五空间智能安全⼤赛真题----------PNG图⽚转换器
- php写一个购买全网最低价的纸尿裤
- DAY4:MySQL 数据库的建立及简单实用
猜你喜欢

IDEA使用JDBC连接MySQL数据库个人详细教程

Seay source code audit system

Thinkphp6管道模式Pipeline使用

HCIA-R&S自用笔记(27)综合实验

Plato Farm有望通过Elephant Swap,进一步向外拓展生态

DAY6:利用 PHP 编写文件上传页面

Wechat applet - component parameter transmission, state management

Detailed installation and use tutorial of MySQL (nanny installation with pictures and texts)

HCIA-R&S自用笔记(25)NAT技术背景、NAT类型及配置

Use QSS to style the form
随机推荐
Common characteristic engineering operations
Starfish OS:以现实为纽带,打造元宇宙新范式
HCIA-R&S自用笔记(24)ACL
[C language series] - a recursive topic
Day14: upload labs customs clearance tutorial
Crypto giants all in metauniverse, and platofarm may break through
Relationship between redrawing and reflow
The openatom openharmony sub forum was successfully held, and ecological and industrial development entered a new journey
The bear market is slow, and bit.store provides stable stacking products to help you get through the bull and bear market
HCIA-R&S自用笔记(25)NAT技术背景、NAT类型及配置
微信小程序-组件传参,状态管理
·Let's introduce ourselves to the way of programming·
Differences between href and SRC
Okaleido tiger logged into binance NFT on July 27, and has achieved good results in the first round
Related knowledge of elastic box
DAY4:SQL Sever 简单使用
量化开发必掌握的30个知识点【什么是分笔逐笔数据】?
dcat 批量操作弹窗及参数传递
熊市下PLATO如何通过Elephant Swap,获得溢价收益?
Set the background color of a cell in the table