getLeft,getTop,getRight,getBottm傻傻分不清.
通过下面图片已经很清晰的把该说的说明白了!

注意:    1.getLeft,getTop,getRight,getBottm,getWidth是View左上角的锚点相对父布局的像素.    2.可以看到父布局在布局文件里面设置了android:padding="20dp".因为density=1.5实质转换为像素应该是30px.

布局文件:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res/com.example.dsliang.viewdemo" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical" android:padding="20dp">    <LinearLayout  android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/GREEN" android:gravity="center" android:orientation="vertical" android:padding="20dp">        <com.example.dsliang.viewdemo.ViewDemo  android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/GRAY" />    </LinearLayout></LinearLayout>

更多相关文章

  1. android反编译工具Apktool安装与使用
  2. Android模拟器中安装apk
  3. Android文件命名规范
  4. Android/JAVA快速入门笔记
  5. 梳理Android的IPC进程间通信(最新AndroidStudio的AIDL操作)
  6. Android(安卓)studio 快捷键小计
  7. Android(安卓)Adapter总结
  8. Android(安卓)Studio导入Fresco项目编译报错unable to expand TA
  9. Android(安卓)开发学习进程0.15 adb cardview framelayout 控件

随机推荐

  1. 50个Android开发人员必备UI效果源码
  2. 【1510-12.2】textview加图片&nbsp…
  3. 50个Android开发人员必备UI效果源码
  4. android高级应用第二阶段
  5. 页面跳转
  6. 50个Android开发人员必备UI效果源码
  7. Android(安卓)屏幕自适应方向尺寸与分辨
  8. 布局的嵌套
  9. android狼人杀源码,桌面源码,猎豹快切源码
  10. Android创建快捷方式,Android检查快捷方式