Align two-button layout left and right in Android -


i want align 2 buttons linear layout, 1 on left, , 1 on right, next , previous buttons on image gallery. tried align them doesn't work.

xml layout code:

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="vertical"     android:background="@android:color/white"     android:gravity="bottom" >       <linearlayout         android:id="@+id/linearlayout1"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:background="@android:color/black" >          <button             android:id="@+id/button1"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="prev"             android:layout_alignparentright="true" />          <button             android:id="@+id/button2"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="next" />      </linearlayout>  </linearlayout> 

actual output:

expected output:

how can fix it?

use relativelayout. there can set android:layout_alignparentleft , android:layout_alignparentright. should work you:

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="vertical"     android:background="@android:color/white"     android:gravity="bottom" >       <relativelayout         android:id="@+id/relativelayout1"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:background="@android:color/black" >          <button             android:id="@+id/button1"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="prev"             android:layout_alignparentleft="true" />          <button             android:id="@+id/button2"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="next"             android:layout_alignparentright="true"/>      </relativelayout>  </linearlayout> 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -