在父控件里面加上两条属性
android:focusable="true"
android:focusableInTouchMode="true"
具体例子
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:focusable="true"
android:focusableInTouchMode="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="流水号"
android:textColor="@android:color/black"
android:textSize="16sp"/>
<EditText
android:id="@+id/etTraceNo"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@null"
android:gravity="end"
android:inputType="number"
android:maxLength="6"
android:text="000001"
android:textSize="16sp"/>
</LinearLayout>