android开发中view的getTop getLeft getBottom getRight返回的坐标点不包括view的margin

android开发中view的getTop getLeft getBottom getRight返回的坐标点不包括view的margin  但包括view的padding

例如:

<?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/nihao"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#b2dfdb"
android:layout_margin="10px"
android:padding="10px"

android:text="你好"/>

</LinearLayout>

TextView的 getTop getLeft getBottom getRight 返回的数值为:

top: 10
left: 10
right: 86
bottom: 68

也就是说:view的getTop getLeft getBottom getRight返回的坐标点不包括view的margin,但包括了view的padding。

返回的是px,也就是像素。

posted on 2018-04-24 18:19  猪猪一号  阅读(595)  评论(0编辑  收藏  举报

导航