1. View的位置信息
通过查看View的源代码,我们知道关于View的位置信息有以下:
1. mLeft、mTop、mRight、mBottom
2. translationX、translationY
3. getX()、getY()
2. demo验证
直接放了两个TextView在布局中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="center"
android:background="#ff0000"
android:textSize="15sp"
android:textColor="#ffffff"
android:text="text1"
/>
<TextView
android:id="@+id/text2"
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="center"
android:background="#00ff00"
android:textSize="15sp"
android:textColor="#ffffff"
android:text="text2"
/></