可能重复:
Android 如何沿着手指画一条平滑线
我使用以下代码创建了布局:
activity_hand_write_demo.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/custom_border">
<TextView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="20dp"
android:textColor="#FFFFFF"
android:gravity="center_horizontal"
android:background="#AAAAAA" />
</LinearLayout>
</LinearLayout>
可绘制的custom_border.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="20dp"/>
<padding android:left="10dp" android:right="10dp" android:top="10dp" android:bottom="10dp"/>
<solid android:color="#1ABCD1"/>
</shape>
HandWriteDemo.java
package com.example.handwritedemo;
import android.os.Bundle;
import android.app.Activity;
public class HandWriteDemo extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hand_write_demo);
}
}
现在我想在手指移动时画一条线。我被卡住了如何通过触摸监听器或其他方式来实现这一点。
如果有人知道...