android - How to stop layout from taking all width -


i have activity , need stop filling width of textview , button. these shown in centre filling width. how stop , make width fixed? please see layout below.

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="1280dp"     android:layout_height="match_parent"     android:gravity="center_vertical|center_horizontal"     android:paddingbottom="@dimen/activity_vertical_margin"     android:paddingleft="@dimen/activity_horizontal_margin"     android:paddingright="@dimen/activity_horizontal_margin"     android:paddingtop="@dimen/activity_vertical_margin"     tools:context=".login" >      <textview         android:id="@+id/lblusername"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentleft="true"         android:layout_centerhorizontal="true"         android:text="@string/username" />      <edittext         android:id="@+id/txt4username"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:layout_alignleft="@+id/lblusername"         android:layout_below="@+id/lblusername"         android:ems="10"         android:inputtype="text|textfilter|textnosuggestions" >          <requestfocus />     </edittext>      <textview         android:id="@+id/lblpassword"         android:layout_width="300dp"         android:layout_height="wrap_content"         android:layout_alignleft="@+id/lblusername"         android:layout_below="@+id/txt4username"         android:layout_margintop="20dp"         android:text="@string/password" />      <edittext         android:id="@+id/txt4password"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:layout_alignleft="@+id/lblpassword"         android:layout_below="@+id/lblpassword"         android:ems="10"         android:inputtype="textpassword" />      <button         android:id="@+id/btnforlogin"         style="?android:attr/buttonstylesmall"         android:layout_width="50dip"         android:layout_height="wrap_content"         android:layout_alignleft="@+id/txt4password"         android:layout_alignright="@+id/txt4password"         android:layout_below="@+id/txt4password"         android:layout_margintop="30dp"         android:maxlength="50"         android:onclick="verification"         android:text="@string/login" />  </relativelayout> 

required highlighted in red enter image description here

change width of parent layout wrap_content, if doesn't change try put margin left , right of parent layout choice

<relativelayout  ... android:layout_width="wrap_content" ...>  or  <relativelayout  ... android:layout_marginleft="somevalue" android:layout_marginright="somevalue" ...> 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -