Aligning Controls
I'm just wasting time with this, because I have no idea how to do it properly. Basically, I want to have a custom input view, where the user can draw whatever he wants with his / h
Solution 1:
Place the custom view above the Buttons
:
<RelativeLayoutxmlns: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"tools:context=".MainActivity" ><Buttonandroid:id="@+id/buttonSave"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:layout_alignParentLeft="true"android:text="@string/save" /><Buttonandroid:id="@+id/buttonQuery"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:layout_alignParentRight="true"android:text="@string/query" /><com.example.myapp.DrawViewandroid:id="@+id/drawView"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_alignParentLeft="true"android:layout_alignParentTop="true"android:layout_above="@id/buttonSave" /></RelativeLayout>
If you aren't sure about the height of the Buttons
being equal you would have to wrap them in another layout(like LinearLayout
) and then place the custom View
above that wrapper.
Solution 2:
Place buttons on some layout:
<RelativeLayoutxmlns: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"tools:context=".MainActivity" ><com.example.myapp.DrawViewandroid:id="@+id/drawView"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_alignParentLeft="true"android:layout_alignParentTop="true" /><RelativeLayoutandroid:id="@+id/button_layout"........android:layout_alignParentBottom="true"
>
....
your buttons
.....
</RelativeLayout></RelativeLayout>
Post a Comment for "Aligning Controls"