Reputation: 351
How can I move views independently from other views in a layout ? For example, I want to be able to move one button up without the other moving but, currently, they are both moving. For more information please see the following image:
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button2"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/button"
android:layout_toEndOf="@+id/button"
/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button3"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="39dp" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button4"
android:layout_alignTop="@+id/button3"
android:layout_alignLeft="@+id/button2"
android:layout_alignStart="@+id/button2" />
Upvotes: 0
Views: 107
Reputation: 1191
You can use a RelativeLayout
to embed the components you want.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="@+id/cardholderNameText"
style="@style/form_label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="@string/cardholder_name" />
</RelativeLayout>
Upvotes: 0
Reputation: 850
First you not posted complete xml layout file. How can some some know what layout you are using.
Solution:You need to put both buttons in different layout if your are using LinearLayout
or you can use Relative Layout
but in Relative Layout
case both buttons should not be depend on each other.
Upvotes: 1