如何在安卓中合成振动模式?
在安卓中实现振动模式的步骤
第一步:创建一个空的活动安卓工作室项目
- Create an empty active Android studio project. And choose Java as the programming language.
- Refer to Android | How to create/start a new project in Android Studio to learn how to create an empty active Android Studio project.
步骤 2:使用 activity_main.xml 文件
- Implement a button in the layout, which is used to create a vibration waveform when pressed.
- Call the following code in the activity _ main.xml file.
XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:ignore="HardcodedText">
<!--button to compose vibration waveforms when pressed-->
<Button
android:id="@+id/makeVibrationCompositionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:backgroundTint="@color/colorPrimary"
android:text="COMPOSE VIBRATION"
android:textColor="@android:color/white" />
</RelativeLayout>
版权属于:月萌API www.moonapi.com,转载请注明出处