当前位置:网站首页>“山东大学移动互联网开发技术教学网站建设”项目实训日志三
“山东大学移动互联网开发技术教学网站建设”项目实训日志三
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
- Wechat applet change attribute value -setdata- bidirectional binding -model
- Sliding switch of tab of uniapp component
- Laravel服务容器(继承与事件)
- Day14: upload labs customs clearance tutorial
- 【电子电路】ADC芯片如何选型
- [untitled]
- The LAAS protocol of defi 2.0 is the key to revitalizing the development of defi track
- WIN10 编译ffmpeg(包含ffplay)
- Introduction to C language array to proficiency (array elaboration)
猜你喜欢
随机推荐
Set the background color of a cell in the table
DAY15(DAY16拓展):文件包含漏洞
[C language series] - storage of deep anatomical data in memory (II) - floating point type
Laravel服务容器(继承与事件)
Masscan使用教程.
与多家机构战略合作,背后彰显PlatoFarm元宇宙龙头的实力
学习、研究编程之道
Question swiping Madness - leetcode's sword finger offer58 - ii Detailed explanation of left rotation string
DAY14:Upload-labs 通关教程
量化开发必掌握的30个知识点【什么是分笔逐笔数据】?
Qt设置背景图片方法
Detailed explanation of typical application code of C language array - master enters by mistake (step-by-step code explanation)
win10+opencv3.2+vs2015配置
Record the SQL injection vulnerability of XX company
Dao race track is booming. What are the advantages of m-dao?
一文读懂Move2Earn项目——MOVE
[JS question solution] questions 1-10 in JS of niuke.com
Hcia-r & s self use notes (26) PPP
Relationship between link and @import
What is nmap and how to use it





![[C language series] - a recursive topic](/img/a2/9d65728e672ab16c4fc0d427c241c4.png)



