思想: 把imgeview 与 EditText用一个相对布局包括 然后设置EditText的paddingleft 的距离
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dip" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/user" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edited_bg"
android:maxLength="20"
android:paddingLeft="25dip"
android:singleLine="true" />
</RelativeLayout>
</LinearLayout>
运行结果:
已经通过 background的属性 改变 edittext 的样式