getLeft,getTop,getRight,getBottm区别
16lz
2021-01-26
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>
更多相关文章
- android反编译工具Apktool安装与使用
- Android模拟器中安装apk
- Android文件命名规范
- Android/JAVA快速入门笔记
- 梳理Android的IPC进程间通信(最新AndroidStudio的AIDL操作)
- Android(安卓)studio 快捷键小计
- Android(安卓)Adapter总结
- Android(安卓)Studio导入Fresco项目编译报错unable to expand TA
- Android(安卓)开发学习进程0.15 adb cardview framelayout 控件