常用的自定义属性
| key | 含义 | 补充说明 |
| — | — | — |
| ml_maxWidth | 最大宽度 | |
| ml_maxheight | 最大高度 | |
| ml_ratio_standard | 指定比例的模式,即是宽高比还是高宽比 | w_h,宽高比, h_w 高宽比 |
| ml_ratio | 比例值 | 只有比例模式是 w_h 或者 h_w,该值才会生效 |
指定最大宽度,高度
指定最大宽度,最大高度,我们值需要使用 ml_maxWidth,ml_maxheight 属性即可,当然我们也可以同时指定最大宽度和最大高度。如下
<com.xj.maxlayout.MaxLayout
android:layout_width=“match_parent”
android:layout_height=“100dp”
android:layout_marginTop=“15dp”
android:background=“@android:color/holo_blue_light”
app:ml_maxWidth=“200dp”>
<TextView
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:layout_gravity=“center”
android:padding=“10dp”
android:text=“指定最大宽度,指定最大宽度,指定最大宽度” />
</com.xj.maxlayout.MaxLayout>
<com.xj.maxlayout.MaxLayout
android:layout_width=“200dp”
android:layout_height=“match_parent”
android:layout_marginTop=“15dp”
android:background=“@android:color/holo_blue_light”
app:ml_maxheight=“200dp”>
<TextView
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:layout_gravity=“center”
android:gravity=“center”
android:padding=“10dp”
android:text=“指定最大高度” />
</com.xj.maxlayout.MaxLayout>
<com.xj.maxlayout.MaxLayout
android:layout_width=“wrap_content”
android:layout_height=“match_parent”
android:layout_marginTop=“15dp”
android:background=“@android:color/holo_blue_light”
app:ml_maxWidth=“200dp”
app:ml_maxheight=“150dp”>
<TextView
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:layout_gravity=“center”
android:padding=“10dp”
android:text=“同时指定最大宽度和最大高度” />
</com.xj.maxlayout.MaxLayout>
指定宽高比
指定宽高比,我们需要设置两个属性,ml_ratio_standard 和 ml_ratio。ml_ratio_standard 有两个值,w_h 代表已宽度为基准,h_w 代表已高度为基准。
比如,我们要指定高度是宽度的某个比例的时候,如,高度是宽度的两倍,可以这样写
<com.xj.maxlayout.MaxLayout
android:id=“@+id/ml_1”
android:layout_width=“100dp”
android:layout_height=“wrap_content”
android:background=“@color/colorAccent”
app:ml_ratio=“2.0”
app:ml_ratio_standard=“w_h”>
<ImageView
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:scaleType=“centerCrop”
android:src=“@mipmap/jsy03” />
</com.xj.maxlayout.MaxLayout>
比如,我们要指定宽度是高度的某个比例的时候,如,宽度是高度的 0.8,可以这样写
<com.xj.maxlayout.MaxLayout
android:id=“@+id/ml_2”
android:layout_width=“match_parent”
android:layout_height=“200dp”
android:layout_marginLeft=“20dp”
android:layout_toRightOf=“@id/ml_1”
android:background=“@android:color/holo_blue_light”
app:ml_ratio=“0.8”
app:ml_ratio_standard=“h_w”>
<ImageView
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:scaleType=“centerCrop”
android:src=“@mipmap/jsy04” />
</com.xj.maxlayout.MaxLayout>
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级安卓工程师,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年最新Android移动开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Android)
点击这里免费领取吧!
里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频**
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Android)
[外链图片转存中…(img-9dI6qUGL-1711299797975)]
[外链图片转存中…(img-DVpAbCM8-1711299797975)]
[外链图片转存中…(img-N8Ddj87q-1711299797975)]