FelasDroid
FelasDroid

Reputation: 643

Error in the Layout setting

Right now I have a layout as in the picture, just that I would like the blue rectangle inside the white rectangle I go to fill the whole size of the white square .. but I tried to change some settings but not works.

The Xml is:

    <merge xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   tools:context=".LoginActivity" >


    <!-- Login progress -->

    <LinearLayout
       android:id="@+id/login_status"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_gravity="center"
       android:gravity="center_horizontal"
       android:orientation="vertical"
       android:visibility="gone" >

        <ProgressBar
           style="?android:attr/progressBarStyleLarge"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_marginBottom="8dp" />

        <TextView
           android:id="@+id/login_status_message"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_marginBottom="16dp"
           android:fontFamily="sans-serif-light"
           android:text="@string/login_progress_signing_in"
           android:textAppearance="?android:attr/textAppearanceMedium" />
    </LinearLayout>

    <!-- Login form -->

    <ScrollView
       android:id="@+id/login_form"
       android:layout_width="fill_parent"
       android:layout_height="match_parent"
       android:background="@color/background_color" >



        <LinearLayout
           style="@style/LoginFormContainer"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:layout_gravity="center_horizontal"
           android:layout_marginTop="20dp"
           android:background="@color/background_login_color"
           android:orientation="vertical" >

        <LinearLayout
       android:id="@+id/row0"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:background="@drawable/top_logo_repeat"
       android:gravity="center"
       android:orientation="vertical" >

        <ImageView
           android:id="@+id/imageLogo"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:antialias="true"
           android:contentDescription="@string/logoimg"
           android:src="@drawable/logo" />

    </LinearLayout>

            <EditText
               android:id="@+id/username"
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:hint="@string/prompt_username"
               android:inputType="textEmailAddress"
                           android:layout_marginTop="20dp"

               android:maxLines="1"
               android:singleLine="true" />

            <EditText
               android:id="@+id/password"
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:hint="@string/prompt_password"
               android:imeActionId="@+id/login"
               android:imeActionLabel="@string/action_sign_in_short"
               android:imeOptions="actionUnspecified"
               android:inputType="textPassword"
               android:maxLines="1"
               android:singleLine="true" />

            <CheckBox
               android:id="@+id/checkBox1"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:text="@string/saveCheckBox" />

            <Button
               android:id="@+id/sign_in_button"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:layout_marginTop="16dp"
               android:paddingLeft="32dp"
               android:paddingRight="32dp"
               android:text="@string/action_sign_in_register" />

            <Button
               android:id="@+id/button1"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:layout_toRightOf="@+id/sign_in_button"
               android:layout_weight="0.30"
               android:text="@string/registerButton" />

        </LinearLayout>

    </ScrollView>

</merge>

Screen Layout

Upvotes: 1

Views: 197

Answers (1)

IAmGroot
IAmGroot

Reputation: 13855

Your linearLayout has style set to LoginFormContainer

<LinearLayout
       style="@style/LoginFormContainer"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:layout_gravity="center_horizontal"
       android:layout_marginTop="20dp"
       android:background="@color/background_login_color"
       android:orientation="vertical" >

In this style, it is likely that margins are set. As such, all contents in the LinearLayout have a margin.

The solution to this, is to remove the margin from the style. (Or remove the style from the LinearLayout.

Note: This will then remove the margins to the editText etc below the image too, as they are also in the linear layout.

The solution to fix this, would be to wrap the rest of the contents in its own LinearLayout and apply the margin to this LinearLayout.

Upvotes: 3

Related Questions