Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/205.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android studio中将图像视图划分为不同数量的部分_Android_Imageview - Fatal编程技术网

如何在android studio中将图像视图划分为不同数量的部分

如何在android studio中将图像视图划分为不同数量的部分,android,imageview,Android,Imageview,我正在尝试将Imageview分成不同数量的部分,所有这些部分都可以单击,并将打开一个新的活动 示例ImageView,我将尝试将其分为47个不同的部分 创建一个47个矩形的数组,用于定义各个部分,如果其中一些矩形包含接触点坐标,则在onTouch handler测试中 private ArrayList<Rect> rectsArray = new ArrayList<>; // add to the array 47 Rect with coordinates of

我正在尝试将
Imageview
分成不同数量的部分,所有这些部分都可以单击,并将打开一个新的活动

示例
ImageView
,我将尝试将其分为47个不同的部分


创建一个47个矩形的数组,用于定义各个部分,如果其中一些矩形包含接触点坐标,则在onTouch handler测试中

private ArrayList<Rect> rectsArray = new ArrayList<>;

// add to the array 47 Rect with coordinates of sections 


// in onTouch handler
int touchedRect = -1;  // -1 means point is outside any section
for (int i == 0; i < 47 ; i++){
    if (rectsArray.get(i).contains(X, Y)){
       touchedRect = i;
       break;
      }
    }
private ArrayList rectsArray=new ArrayList;
//添加到带有截面坐标的数组47 Rect
//在OnTouchHandler中
int touchedRect=-1;//-1表示点位于任何截面之外
对于(int i==0;i<47;i++){
if(rectsArray.get(i).contains(X,Y)){
touchedRect=i;
打破
}
}

使用带有背景图像的GridView。和透明的文本视图被用作“按钮”。我会使用47个背景图像吗?我告诉过你吗?我告诉过你:
。。。带有**1**背景图像
。因为文本视图是透明的,所以您可以看穿它们。你会看到他们父母的背景。这只是一个样本图像视图。我有48幅图像,有不同数量的部分???很难用所有的部分来制作所有的背景图像。然后用一个图像来制作所有的按钮。您可能更喜欢使用GridLayout而不是GridView,因为单元格可以有五种不同的大小。