<RelativeLayout
android:layout_width="match_parent"
android:gravity="right"
android:layout_height="30dp">
<EditText
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@drawable/d1"
/>
<ImageView
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:src="@mipmap/ic_calendar">
</ImageView>
</RelativeLayout>
主要是: android:layout_alignParentRight=“true” //对齐父布局的右边
android:layout_centerVertical=“true” //垂直居中开启