I would like the radio button options to show up at the top, and the picture right below. How should I go about this? I have been playing around with putting my custom view in a linear layout and then setting android:orientation = horizontal
but I don't think that works like I think it does.
My activity_main.xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioGroup
android:id="@+id/greyorcolor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/grey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Greyscale" />
<RadioButton
android:id="@+id/color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Color" />
</RadioGroup>
<RadioGroup
android:id="@+id/smallorlarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Large" />
<RadioButton
android:id="@+id/small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Small" />
</RadioGroup>
</LinearLayout>
<edu.berkeley.cs160.opalkale.prog2.DrawingView
android:id="@+id/drawing"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_marginBottom="3dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="3dp"
android:layout_weight="1"
android:orientation="vertical"
android:src="@drawable/crayon" />
</LinearLayout>
Here is your corrected XML portion.
<edu.berkeley.cs160.opalkale.prog2.DrawingView
android:id="@+id/drawing"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_marginBottom="3dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="3dp"
android:layout_weight="1"
android:orientation="vertical"
android:src="@drawable/ic_launcher" />
You are putting "0dip" in android:layout_width instead of android:layout_height thats why you are getting the result. Replace this corrected XML portion, you will get your Layout right.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments