android data binding jetpack VIIII 第一坑
2024-09-04 01:01:50
<LinearLayout
android:id="@+id/ll_item_home_page_pics"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/rl_item_home_page_top"
android:layout_marginTop="10dp"
android:orientation="horizontal"> <ImageView
android:id="@+id/iv_pic0"
android:layout_width="0dp"
android:layout_height="80dp"
android:layout_weight="1"
android:scaleType="fitXY"
android:src="@drawable/tempic"
bind:url="@{product.imgUrls.get(0)}"
tools:ignore="ContentDescription" /> <ImageView
android:id="@+id/iv_pic1"
android:layout_width="0dp"
android:layout_height="80dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_weight="1"
android:scaleType="fitXY"
android:src="@drawable/tempic1"
bind:url="@{product.imgUrls.get(1)}"
tools:ignore="ContentDescription" /> <ImageView
android:id="@+id/iv_pic2"
android:layout_width="0dp"
android:layout_height="80dp"
android:layout_weight="1"
android:scaleType="fitXY"
android:src="@drawable/tempic2"
bind:url="@{product.imgUrls.get(2)}"
tools:ignore="ContentDescription" />
</LinearLayout>
如上代码,三张图片一行均分布局,LinearLayout + android:layout_weight="1" 很正常的做法。使用glide给图片绑定。
结果-->>>>>图片全出不来。
简单分析也不知道哪个环节出问题了。根本问题是图片的宽高没了。
项目紧先给个解决方案,后期再分析原因。
改用tablelayout 后正常。没到测试期,不知道其它版本系统是不是有问题。
<TableLayout
android:id="@+id/ll_item_home_page_pics"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/rl_item_home_page_top"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:stretchColumns="*"> <TableRow> <ImageView
android:id="@+id/iv_pic0"
android:layout_width="0dp"
android:layout_height="80dp"
android:scaleType="fitXY"
android:src="@drawable/tempic"
bind:url="@{product.imgUrls.get(0)}"
tools:ignore="ContentDescription" /> <ImageView
android:id="@+id/iv_pic1"
android:layout_width="0dp"
android:layout_height="80dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:scaleType="fitXY"
android:src="@drawable/tempic1"
bind:url="@{product.imgUrls.get(1)}"
tools:ignore="ContentDescription" /> <ImageView
android:id="@+id/iv_pic2"
android:layout_width="0dp"
android:layout_height="80dp"
android:scaleType="fitXY"
android:src="@drawable/tempic2"
bind:url="@{product.imgUrls.get(2)}"
tools:ignore="ContentDescription" />
</TableRow> </TableLayout>
注意使用:android:stretchColumns="*" 基本跟android:layout_weight 功能一致。
最新文章
- 【引】objective-c,5:Associated Objects 的原理
- 非阻塞同步算法实战(二)-BoundlessCyclicBarrier
- HDU3820 Golden Eggs(最小割)
- 基于HTML5技术的电力3D监控应用(四)
- fragment入门
- ylbtech-dbs:ylbtech-PurpleBill(票据管理系统)
- Java通过代理类实现数据库DAO操作
- Java语言基础(三)
- Qt on Android:QTableView不显示选中虚框
- Kotlin Vertx
- Android OpenGL ES(十一)绘制一个20面体 .
- http://codeforces.com/contest/845
- 2017上海QCon之旅总结(中)
- Python之matplotlib学习(三)
- splay详解(二)
- 第一章 C#入门 (Windows窗体应用程序)(一)
- 使有prometheus监控redis,mongodb,nginx,mysql,jmx
- Spring Data JPA方法定义规范
- PostgreSQL之连接数修改
- jmeter:正则表达式的使用
热门文章
- Node.js学习(1)-加载模块require(&#39;fs/http/.b/art-template&#39;)
- elmentUI为table中的单元格添加事件
- Java秒杀实战 (六) 服务级高并发秒杀优化(RabbitMQ+接口优化)
- CDH5.16.1的agent启动报错:ERROR Error, CM server guid updated, expected d9bcadb4-f983-41b8-a667-66760f47bc91, received a67f5efa-8473-4f6a-94d6-231d1f432ef0
- fnmatch:Unix式glob模式匹配,简单场景下可以代替正则
- Cacti-0.8.8b详细安装及配置步骤
- 4.caffe资源汇总(更新中)
- bug-- java.lang.RuntimeException: Type “Klass*";
- new函数
- 这个是自定义的代码块在xcode中的路径