I want to find the presentation position on the display screen.
For this, I use methods such as view.getLeft() , view.getBottom() , view.getRight() , view.getTop() . But unfortunately all of these methods return 0 .
Is there an alternative way to find the position of the view (for example, the coordinates on the screen)?
My main.xml layout:
<TextView android:id="@+id/tv1" android:layout_width="200px" android:layout_height="30px" android:text="welcome to" /> <TextView android:id="@+id/tv2" android:layout_width="200px" android:layout_height="30px" android:text=" Make Eit solution " />
And my class has this in onCreate() :
super.onCreate(savedInstanceState); setContentView(R.layout.main); tv1 = (TextView) findViewById(R.id.tv1); tv2 = (TextView) findViewById(R.id.tv2); System.out.println("tv4 width:"+tv2.getWidth()); System.out.println("tv4 height:"+tv2.getHeight()); System.out.println("Right:"+tv2.getRight()); System.out.println("Left:"+tv2.getLeft()); System.out.println("Top:"+tv2.getTop()); System.out.println("Bottom:"+tv2.getBottom());
android android-layout android-view
Balaji.k
source share