Как я могу выровнять LinearLayout «LoginBox» со своим родителем (это RelativeLayout) как слева, так и справа? Я попытался вставить:Выровнять LinearLayout внутри проблемы RelativeLayout
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
но это не делает трюк! Infact linearlayout не правильно выровнен с краем экрана! :(
Это мой XML-код:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/sfondologin"
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=".MainActivity" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/stemmatrasparente" />
<LinearLayout
android:id="@+id/LoginBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="@+id/usernametxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="@drawable/sfondobuttonedittext"
android:drawableLeft="@drawable/usericon"
android:ems="10"
android:gravity="center_horizontal|center"
android:paddingLeft="15dp"
android:imeOptions="actionNext"
android:singleLine="true"
android:textSize="18dp"
android:typeface="sans" >
<requestFocus />
</EditText>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.18" >
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<EditText
android:id="@+id/passwordtxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="@drawable/sfondobuttonedittext"
android:drawableLeft="@drawable/lockicon"
android:ems="10"
android:gravity="center_vertical|center"
android:inputType="textPassword"
android:paddingLeft="15dp"
android:imeOptions="actionDone"
android:textSize="18dp"
android:typeface="sans" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.29" >
<TextView
android:id="@+id/forgotpass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Dimenticato la password?"
android:textColor="@color/white"
android:textColorHint="@color/white"
android:textSize="@dimen/value12dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/loginbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/sfondobuttonlogin"
android:text="Login"
android:textColor="@color/white" />
</RelativeLayout>
<Button
android:id="@+id/registerbtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center|end"
android:background="@drawable/sfondobuttonrb2"
android:text="Registrati"
android:textColor="@color/white" />
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="left"
android:layout_weight="0.01"
android:background="#00000000">
</RelativeLayout>
</RelativeLayout>
Спасибо заранее
EDIT: Первый экран то, что я есть сейчас, пока второй, отредактированы фотошопе (извините) , является то, что я хочу, чтобы получить
Я не уверен, чего вы пытаетесь достичь - пытаетесь ли вы сделать макет заполнить родителя или пытаетесь его центрировать? выравнивание влево и вправо не будет работать, потому что вы пытаетесь вытащить начало и заканчиваться в разных направлениях. –
попробуйте использовать Linear Layout как родительский, а затем Make child for Relative –