当前位置:网站首页>“山东大学移动互联网开发技术教学网站建设”项目实训日志三
“山东大学移动互联网开发技术教学网站建设”项目实训日志三
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的开发和教学设计
边栏推荐
- 记xx公司SQL注入漏洞
- nmap是什么以及使用教程
- 马斯克推崇的柏拉图式元宇宙,PlatoFarm早已验证出答案
- 365 day challenge leetcode1000 question - day 036 binary tree pruning + subarray and sorted interval sum + delete the shortest subarray to order the remaining arrays
- Record the SQL injection vulnerability of XX company
- Use QSS to style the form
- From starfish OS' continued deflationary consumption of SFO, the value of SFO in the long run
- 完全去中心化的编程模式,不需要服务器,也不需要ip,就像一张漫无目的的网络、四处延伸
- uniapp组件之tab选项卡滑动切换
- Strategic cooperation with many institutions shows the strength of the leading company of platofarm yuancosmos
猜你喜欢

一文读懂Move2Earn项目——MOVE

Laravel Swagger添加访问密码

DAY13:文件上传漏洞

新手入门:手把手从PHP环境到ThinkPHP6框架下载

Win10 搭建MSYS2环境

Hcia-r & s self use notes (24) ACL

熊市慢慢,Bit.Store提供稳定Staking产品助你穿越牛熊

农村品牌建设给年轻人的一些机会

Masscan tutorial

The bear market is slow, and bit.store provides stable stacking products to help you get through the bull and bear market
随机推荐
·Let's introduce ourselves to the way of programming·
改哭了,终于解决了Cannot read properties of undefined (reading ‘parseComponent‘)
The completely decentralized programming mode does not need servers or IP, just like a aimless network extending everywhere
365 day challenge leetcode 1000 questions - day 035 one question per day + two point search 13
link与@import的关系
What is wapiti and how to use it
ThinkPHP6 输出二维码图片格式 解决与 Debug 的冲突
Sports health is deeply rooted in the hearts of the people, and move protocol leads quality life
Win10 compiles ffmpeg (including ffplay)
table中同一列中合并相同项
7 月 28 日 ENS/USD 价值预测:ENS 吸引巨额利润
Thinkphp6管道模式Pipeline使用
[C language series] - string + partial escape character explanation + annotation tips
一文读懂Move2Earn项目——MOVE
[C language series] - constants and variables that confuse students
nmap是什么以及使用教程
JS simple code determines whether the device that opens the page is the PC end of the computer, the H5 end of the mobile phone, or the wechat end
[typescript] learn typescript object types in depth
我的理想工作,码农的绝对自由支配才是最重要的——未来创业的追求
Fantom (FTM) 在 FOMC会议之前飙升 45%