Android UI: Size 2 view?



Good day everyone, currently i'm trying to make my first Android app, and then the first thing i realized, that idiotic XML UI designing.


I have this 2 view (button) and i'd like to make them so the first one fill the half of the parent (RelativeLayout) and the second one fills the other half of the parent... My Code is:



<Button
android:id="@+id/Top1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@id/Top2"
android:text="top1"/>
<Button
android:id="@+id/Top2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/Top1"
android:text="TOP2"/>


The problem, that i'm get this error: "No resource found that matches the given name (at 'layout_toLeftOf' with value '@id/Top2')."


It seems, that not even Android want to use XML but doing it very "retardly"... Like an old C program where if a method is written below the call, it will give an error...


So i have 2 question: 1: How to solve this problem in the XML? 2: Or can i avoid this XML designing, and use code-like design like in C# ?


No comments:

Post a Comment