我正在努力寻找与众不同的游戏应用程序,但我从未做过类似的事情,而且由于我是开发新手,我陷入了困境
好的宝贝 学习xD总是需要步骤
我在一些文档中读到我必须分别获取每个 ImageView 的高度和宽度,所以当我触摸 imageView1 时,它的坐标可以设置为 ImageVIew2 和 ViceVersa 我可能是错误的 XD
现在我有一个垂直设置的 2 个图像的布局
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PlayActivity"
android:id="@+id/hello1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/hello">
<ImageView
android:id="@+id/image1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/pic_9" />
<ImageView
android:id="@+id/image2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/pic_9a" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我想要做的是,如果我点击 image1 中的一个地方,应该在 image2 的同一个地方创建一个圆圈
阅读了一些内容后,如果我点击布局,我就画了一个圈,但在此之后我被卡住了,我找不到下一步该做什么,也许我找不到与我的问题相关的文档
public class PlayActivity extends AppCompatActivity {
RelativeLayout layout;
float x = 0;
float y = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_play);
layout=(RelativeLayout) findViewById(R.id.hello1);
layout.addView(new CustomView(PlayActivity.this));
}
public …Run Code Online (Sandbox Code Playgroud) android ×1