Reputation: 381
Currently I am having 2 pictures per row (loaded via Picasso) with a checkbox at the top right corner of each of them. When I try to add a Scrollview, the position of the checkboxes get changed and there is an extra row that appears. how can I add it and keep the rest of the visualization in the correct order? here is my code so far (for a row):
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fadeScrollbars="false"
android:fillViewport="true"
android:orientation="vertical">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linLay"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_marginTop="10dp">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageView
android:id="@+id/img1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp" />
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text=""
android:background="@android:color/white"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageView
android:id="@+id/img2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1" />
<CheckBox
android:id="@+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text=""
android:background="@android:color/white"/>
</RelativeLayout>
</LinearLayout>
Upvotes: 1
Views: 39
Reputation: 171
Set the properties of your UI Elements as Right and Left of parent UI element.
android:layout_below="@id/name"
android:layout_toRightOf="@id/description"
android:layout_toLeftOf="@id/description"
Edit: I make this Example Code for you: This is not the Exact, you can take idea from this.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:id="@+id/parentLayout"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_marginTop="10dp">
<RelativeLayout
android:layout_width="0dp"
android:layout_toRightOf="@+id/parentLayout"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageView
android:id="@+id/img1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp" />
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text=""
android:background="@android:color/white"/>
</RelativeLayout>
Check this Link: Layout File - Positioning Item to Right of Another Item (Android)
Upvotes: 2