通过检测多点触摸将屏幕划分为6个区域

时间:2014-09-06 09:13:15

标签: android

我是android的绝对初学者,我找到了一个检测多头的代码和另一个将屏幕分成6个区域的代码 这是每个代码的布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="horizontal" >

    <LinearLayout     
        android:background="@android:color/black"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="horizontal" >
    </LinearLayout>

    <LinearLayout
        android:background="@android:color/white"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="horizontal" >
    </LinearLayout>
</LinearLayout>


<LinearLayout   
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="horizontal" >

    <LinearLayout
        android:background="@android:color/black"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="horizontal" >
    </LinearLayout>

    <LinearLayout
        android:background="@android:color/darker_gray"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="horizontal" >
    </LinearLayout>


</LinearLayout>

<LinearLayout

    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="horizontal" >

    <LinearLayout
        android:background="@android:color/white"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="horizontal" >
    </LinearLayout>

    <LinearLayout
        android:background="@android:color/black"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="horizontal" >
    </LinearLayout>


</LinearLayout>

用于检测多音色的

布局:

    <com.example.multitouch.MultitouchView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    />

我的问题是如何结合这两种布局?以及如何知道哪个区域所处的触摸? 提前致谢

1 个答案:

答案 0 :(得分:0)

制作布局的父级 - RelativeLayout并将<{1}} match_parent 添加到所有视图上方的所有视图的所有视图中。使用标记View隐藏此视图。 并添加此视图View.INVISIBLE。这就是全部。