方法可以是,在外层的Layout(如LinearLayout),加一句:
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
>
<EditText
android:layout_width="390px"
android:layout_height="90px"
android:background="@drawable/print_bill_bg"
android:layout_marginLeft="20px"
android:layout_gravity="center"
/>
</LinearLayout>
然后在代码中让此layout获得焦点。
LinearLayout linearLayout = view.findViewById(R.id.linearLayout);
linearLayout.requestFocus();
即可。