并不一定要用android:drawableLeft="@drawable/icon"
这种方法
教大家一种简单的
稍微说一下这个布局
其实就是LinearLayout
横向布局套了两个控件,一个EditText
,一个ImageView
要注意的是,EditText
他有下划线那些样式,通过这个android:background="@null"
清除掉就可以
最后LinearLayout
加个背景就行了
emmm,我是不是讲复杂了
看图能不能理解
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:background="@drawable/edit_background"
android:layout_height="wrap_content">
<EditText
android:textSize="14dp"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:enabled="true"
android:gravity="top"
android:inputType="textMultiLine"
android:minHeight="20dp"
android:minLines="2"
android:maxLines="2"
android:scrollbars="vertical"
android:background="@null"
/>
<ImageView
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:padding="9dp"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@mipmap/share_icon"
></ImageView>
</LinearLayout>
这个是android:background="@drawable/edit_background"
对应的样式
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
android:shape="rectangle">
<solid android:color="#efefef"/>
<corners android:radius="5dp"/>
<stroke
android:width="1dp"
android:color="#505050"/>
</shape>
</item>
</layer-list>
响应我就不用多说了吧,给图片添加一个点击事件就可以了。。。