zoukankan      html  css  js  c++  java
  • android data binding jetpack VIIII 第一坑

     <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 功能一致。
  • 相关阅读:
    C++(四十)— C++中一个class类对象占用多少内字节
    C++(三十九) — 主函数中增加调试信息
    C++(三十八) — 继承方式、访问控制、构造和析构、虚继承
    ambari部署Hadoop集群(1)
    小波分析和多尺度几何分析
    正则化与矩阵范数
    设计模式之:创建型设计模式
    设计模式六大原则(详细)
    UML类关系(依赖,关联,聚合,组合,泛化,实现)
    SSD详解
  • 原文地址:https://www.cnblogs.com/mamamia/p/10177846.html
Copyright © 2011-2022 走看看