当前位置:网站首页>“山东大学移动互联网开发技术教学网站建设”项目实训日志三
“山东大学移动互联网开发技术教学网站建设”项目实训日志三
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的开发和教学设计
边栏推荐
- Fvuln automated web vulnerability detection tool
- 一文读懂Move2Earn项目——MOVE
- uniapp组件之tab选项卡滑动切换
- 第五空间智能安全⼤赛真题----------PNG图⽚转换器
- Crypto giants all in metauniverse, and platofarm may break through
- Starfish OS:以现实为纽带,打造元宇宙新范式
- Selection options of uniapp components (such as package selection)
- 农村品牌建设给年轻人的一些机会
- HCIA-R&S自用笔记(27)综合实验
- [typescript] learn typescript object types in depth
猜你喜欢

Fvuln automated web vulnerability detection tool

与开源项目同步开发& CodeReview & Pull Request & fork怎么拉取原始仓库

Qt布局管理--部件拉伸(Stretch)原理及大小策略(sizePolicy)

Crypto giants all in metauniverse, and platofarm may break through

微信小程序-组件传参,状态管理

365 day challenge leetcode1000 question - day 036 binary tree pruning + subarray and sorted interval sum + delete the shortest subarray to order the remaining arrays

The Platonic metauniverse advocated by musk has long been verified by platofarm

Masscan tutorial

Solve the problem that the prompt information of form verification does not disappear and the assignment does not take effect

DAY6:利用 PHP 编写文件上传页面
随机推荐
记xx公司SQL注入漏洞
Dao race track is booming. What are the advantages of m-dao?
The openatom openharmony sub forum was successfully held, and ecological and industrial development entered a new journey
Character type conversion
HCIA-R&S自用笔记(26)PPP
The Platonic metauniverse advocated by musk has long been verified by platofarm
How can Plato obtain premium income through elephant swap in a bear market?
极致通缩和永动机模型,将推动 PlatoFarm 爆发
Use QSS to style the form
Wechat applet change attribute value -setdata- bidirectional binding -model
Solve the problem that the prompt information of form verification does not disappear and the assignment does not take effect
Qtcreator+cmake compiler settings
7 月 28 日 ENS/USD 价值预测:ENS 吸引巨额利润
【TypeScript】TypeScript中类型缩小(含类型保护)与类型谓词
Read and understand move2earn project - move
[sword finger offer] - explain the library function ATOI and simulate the realization of ATOI function
一文读懂Move2Earn项目——MOVE
Fvuln automated web vulnerability detection tool
Set the background color of a cell in the table
SQL修复重复数据