Hi, I'm trying to make Hotspot on an image, but the problem is that the location of the access point for resizing the screen also has changes
I have done the following things at the moment
Bellow is my layout file
<?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"
android:gravity="center"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="myapp.imagemappingdemo.MainActivity">
<FrameLayout
android:layout_width="7000pt"
android:layout_height="5000pt">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/bolt_int"
android:text="Hello World!" />
<RelativeLayout
android:id="@+id/upperView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
>
</RelativeLayout>
</FrameLayout>
I use the following code to build an image.
screenWidth = this.getResources().getDisplayMetrics().widthPixels;
ImageView btn = new ImageView(MainActivity.this);
RelativeLayout.LayoutParams bp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
bp.leftMargin = (int) (774.6667 );
bp.topMargin = (int) (413.25);
btn.setLayoutParams(bp);
btn.setImageResource(R.drawable.ic_stat_name);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainActivity.this, "Button Click", Toast.LENGTH_LONG).show();
}
});
upperview.addView(btn, bp);
I'm trying to figure out how I am going to accurately determine the position on another screen using the same (X, Y) coordinate, can someone help me with this, what is the relationship between the height and width of the screen and (X, y), regardless screen size
source
share