Search code examples
androidxmlandroid-linearlayout

LinearLayout elements sizes XML


I can make something like this in my layout but I want to put the ok button at right. But when I try to make this I have this instead of.

here is my code(second image).

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="#00cc33"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
    
    <LinearLayout
        android:background="#0033cc"
        android:layout_width="fill_parent"
        android:layout_height="95dip"
        android:orientation="horizontal">

        <EditText
            android:text="Enter text"
            android:layout_width="match_parent"
            android:layout_height="95dip"/>

        <Button
            android:text="OK"
            android:layout_height="95dip"
            android:layout_width="95dip"/>
        
    </LinearLayout>
    
</LinearLayout>

I hope it's possible to make this using only XML?


Solution

  • Maybe, you need to use RelativeLayoutand specify attributes related to disposition of elements. Try to check here: https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams