Reputation: 111
my xml code-->>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
tools:context=".MainActivity" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="@+id/team_a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="16dp"
android:text="@string/team_a" />
<TextView
android:id="@+id/team_a_score"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="16dp"
android:text="@string/team_a_score"
android:textSize="56sp" />
<Button
android:id="@+id/three_but"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_marginTop="8dp"
android:background="#ff9800"
android:onClick="addThreeForA"
android:text="@string/three_but"
android:textAllCaps="true" />
<Button
android:id="@+id/two_but"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_marginTop="8dp"
android:background="#ff9800"
android:onClick="addTwoForA"
android:text="@string/two_but"
android:textAllCaps="true" />
<Button
android:id="@+id/one_but"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_marginTop="8dp"
android:background="#ff9800"
android:onClick="addOneForA"
android:text="@string/one_but"
android:textAllCaps="true" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="16dp"
android:background="@android:color/darker_gray" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="@+id/team_b"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="16dp"
android:text="@string/team_b" />
<TextView
android:id="@+id/team_b_score"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="16dp"
android:text="@string/team_b_score"
android:textSize="56sp" />
<Button
android:id="@+id/three_but_b"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_marginTop="8dp"
android:background="#ff9800"
android:onClick="addThreeForB"
android:text="@string/three_but_b"
android:textAllCaps="true" />
<Button
android:id="@+id/two_but_b"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_marginTop="8dp"
android:background="#ff9800"
android:onClick="addTwoForB"
android:text="@string/two_but_b"
android:textAllCaps="true" />
<Button
android:id="@+id/one_but_b"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_marginTop="8dp"
android:background="#ff9800"
android:onClick="addOneForB"
android:text="@string/one_but_b"
android:textAllCaps="true" />
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/reset"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="200dp"
android:layout_marginBottom="16dp"
android:background="#ff9800"
android:onClick="resetAll"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="@string/reset"
android:textAllCaps="true" />
</RelativeLayout>
</ScrollView>
The scrollView works correctly when the app is in portrait mode but when it is in landscape mode the scrollView works but the reset button does not remain in the bottom position as like as portrait mode. How can i solve this problem? Also the RelativeLayout's attribute layout_height = "match_parent" shows a warning that it should be wrap_content. help me to solve this problem?? i'm a novice.
Upvotes: 1
Views: 1334
Reputation: 2903
ScrollView
is not working well with RelativeLayout
please use
<Scrollview>
<LinearLayout>
<RelativeLayout>
**everything else**
</RelativeLayout>
<Button .. />
</LinearLayout>
</Scrollview>
Upvotes: 1