Monday 15 June 2015

android - button not displaying right side of the layout in andoid -



android - button not displaying right side of the layout in andoid -

hi in layout have 2 button's named , home same names mentioned id's both.now left side want display button , right side corner want display home.but home button not displaying @ right corner.now if mention margin left it's not showing properly.can 1 please help me

xml

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <linearlayout android:layout_width="match_parent" android:layout_height="30dp" android:background="#ff0000" android:orientation="horizontal"> <button android:id="@+id/back" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/back" /> <textview android:id="@+id/tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:textstyle="bold" /> <button android:id="@+id/home" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/home" android:layout_marginleft="60dp" /> </linearlayout> </linearlayout>

try this,

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <linearlayout android:layout_width="match_parent" android:layout_height="30dp" android:background="#ff0000" android:orientation="horizontal" android:weightsum="100" > <button android:id="@+id/back" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="left" android:layout_weight="20" android:background="@drawable/back" /> <textview android:id="@+id/tv" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="60" android:gravity="center" android:text="hello" android:textstyle="bold" /> <button android:id="@+id/home" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="right" android:layout_marginleft="60dp" android:layout_weight="20" android:background="@drawable/home" /> </linearlayout> </linearlayout>

android

No comments:

Post a Comment