在父控件里面加上
android:focusable="true"
android:focusableInTouchMode="true"
这样就可以实现。
全部代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<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>
</ScrollView>
</LinearLayout>