一.在drawable中写入
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="1.0px"/>
<stroke android:color="#50FFFFFF" android:width="2px" />
<solid android:color="#50FFFFFF"/>
<!--50代表透明度-->
</shape>
二.在xml文件中
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--RelativeLayout中设置居中图片-->
<!--android:layout_centerInParent="true"-->
<!--设置拉伸图片 填满-->
<!--android:scaleType="fitXY"-->
<ImageView
android:id="@+id/img"
android:layout_width="158dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:layout_marginTop="8dp"
android:background="@drawable/shape_gray_square_bg"
android:padding="5dp"
android:scaleType="fitXY"/>
</RelativeLayout>