I have a LinearLayout in my layout as show in the below diagram with blue background. How can I get the corner coordinate positions?Or How can I set them to specific positions?.For example I want the top-left corner to be at (50,50),top-right corner to be at (300,50),bottom left corner to be (50,200) and the bottom right to be at (300,50) as shown in the figure below.The position here are in px not in dp. My question somehow resemble this question How do android screen coordinates work?
The following is the xml file of the layout:
<?xml version="1.0" encoding="utf-8"?>
<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=".TestActivity">
<LinearLayout
android:layout_width="300px"
android:layout_height="150px"
android:background="@color/colorAccent"
android:orientation="vertical"
android:layout_centerInParent="true"
android:id="@+id/linearLayout"
>
</LinearLayout>
</RelativeLayout>
Is there any way to do this in android studio.I have searched a lot and went through the android developer documentation but did not understand anything. I will be very grateful for your kind feedback on this.
Thanks!