I have a layout of the following structure (some items and attributes omitted for brevity):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical">
<ScrollView android:orientation="vertical">
<TableLayout android:layout_width="match_parent"
android:layout_height="wrap_content">
...
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Label" android:textAppearance="?android:attr/textAppearanceMedium"/>
<RelativeLayout
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content">
<Button
android:id="@+id/btnSaveStep"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Save"/>
<EditText
android:id="@+id/etStep"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/btnSaveStep"
android:ems="10"
android:textAlignment="viewEnd"
android:inputType="numberDecimal"
android:selectAllOnFocus="true"
android:text="10"/>
</RelativeLayout>
</TableRow>
...
</TableLayout>
</ScrollView>
<Button
android:id="@+id/btnProceed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="Proceed"/>
</LinearLayout>
Note the android:descendantFocusability="beforeDescendants"
and android:focusableInTouchMode="true"
attributes of the RelativeLayout
- they had no effect. I also tried this solution, and I placed that dummy layout in numerous places of the layout - all to no avail.