布局文件zxing_save.xml中ImageView用来显示二维码图片。问题:二维码图片长宽比是1比1,ImageView没有属性可以指定长宽比为1比1。解决方法:新建ResizeFrameLayout,扩展FrameLayout,设定长宽比为1比1,将ImageView作为child放在ResizeFrameLayout中,ImageView的width和height设置为match_parent。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tvie="http://schemas.android.com/apk/res/com.tvie.xj.ivideo"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#000000" >
    <com.tvie.base.widget.ResizeFrameLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_centerInParent="true"
        android:layout_margin="10dp"
        android:background="#FF0000"
        android:padding="3dp"
        tvie:ratioXY="1.0" >
        <ImageView
            android:id="@+id/zxingImage"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:background="#00FF00"
            android:padding="6dp" />
    </com.tvie.base.widget.ResizeFrameLayout>
    <Button
        android:id="@+id/btnSave"
        android:layout_width="fill_parent"
        android:layout_height="40dp"
        android:layout_alignParentBottom="true"
        android:layout_margin="5dp"
        android:background="@drawable/logout_selector"
        android:text="保存到本地"
        android:textColor="#0E1700"
        android:textSize="22sp" />
    <include layout="@layout/title_bar_zxing" />
</RelativeLayout>