android图片显示问题

Xml布局

 <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">
                 <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:text="营业执照"
                            android:layout_marginLeft="12dp"
                            android:textColor="@color/defcolor2" />

                    <ImageView
                        android:id="@+id/iv_companyPic"
                        android:layout_width="148dp"
                        android:layout_height="100dp"                          
                        android:layout_marginLeft="12dp"
                        android:layout_marginVertical="5dp"/>
</LinearLayout>     

之后发现从接口中获取URL时会出现图片比例不正确或者图片变得很难看

查找后发现ImageView中缺少

android:scaleType="centerInside"

意思为

将图片的内容完整居中显示,通过按比例缩小或原来的size使得图片长/宽等于或小于View的长/宽

这样设置ImageView固定值的大小也可以按正常比例展示出缩略图了



posted @ 2021-01-05 14:41  null_lii  阅读(83)  评论(0)    收藏  举报