I need to learn creating relativelayouts with java code instead of XML code.
for example, will be nice to understand how to build this XML with java code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/btnButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1"/>
<Button
android:id="@+id/btnButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 2"
android:layout_toRightOf="@+id/btnButton1"/>
<Button
android:id="@+id/btnButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 3"
android:layout_below="@+id/btnButton1"/>
</RelativeLayout>
I can’t find any examples of doing this with java code
Please, can someone help me to transform that layout into java code? or can someone give me tutorial links to do relativelayouts with java code?
thanks
there are plenty of examples out there! Try this tutorial, it covers all elements that you need… And best, it gives programmatically examples for all kind of layouts, so it will solve future questions, too 😉
http://mobile.tutsplus.com/tutorials/android/android-user-interface-design-relative-layouts/