1

I am working on a login screen for my app. The issue is I am getting a white line at the bottom of the screen on every device and on the emulator as well. You can check the output here: http://www.imgur.com/cTMu4Ap This is my xml code for the layout. Please note that I am using layout_weight property for equal space among all devices.

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="0.5"
        android:src="@mipmap/ic_launcher"
        android:layout_gravity="center"
        />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="vertical"
        android:paddingLeft="55dp"
        android:paddingRight="55dp"
        android:background="@color/colorPrimary"
        >
        <EditText
            android:id="@+id/edtEmailOrMobileNumber"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/email_or_mobile_number"
            android:background="@null"
            android:inputType="textEmailAddress"
            android:textColor="@android:color/white"
            android:textColorHint="@android:color/white"
            android:drawableLeft="@drawable/ic_clear"

            android:layout_marginTop="64dp"
            />
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@android:color/white"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp"
            />
        <EditText
            android:id="@+id/edtPassword"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/password"
            android:background="@null"
            android:inputType="textPassword"
            android:textColor="@android:color/white"
            android:textColorHint="@android:color/white"
            android:drawableLeft="@drawable/ic_clear"
            android:drawableRight="@drawable/ic_clear"

            android:layout_marginBottom="20dp"
            />
        <Button
            android:id="@+id/btnSignIn"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/sign_in"
            android:layout_gravity="center"
            android:textColor="@color/blue_login_button"
            android:background="@drawable/rounded_corner_button_login_background"
            android:textAllCaps="false"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:text="@string/dont_have_an_account"
            android:layout_gravity="center"
            android:gravity="center|bottom"
            android:paddingBottom="30dp"
            android:textColor="@android:color/white"
            />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.2"
        android:orientation="vertical"
        android:gravity="center"
        android:background="@drawable/button_create_account_background"
        android:clickable="true"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/create_an_account"
            android:textColor="@android:color/white"
            />
    </LinearLayout>

</LinearLayout>
Shaw
  • 173
  • 2
  • 11
  • 2
    It could be in @drawable/button_create_account_background . Also, try adding android:weightSum="1.7" to your main LinearLayout. – natario Oct 08 '15 at 07:23
  • You can try put the `backgroundColor`on you first (and principal) `LinearLayout` to the same color `Create Account Button` – Aspicas Oct 08 '15 at 07:26
  • @Aspicas: yes its working, thanks. But I want to know the reason of this white line please. What am I doing wrong? – Shaw Oct 08 '15 at 07:34
  • try adding android:padding = "0dp" to your last linear layout – dsharew Oct 08 '15 at 07:34
  • @user2787602 It's because the elements on screen don't fill a full screen, maybe you have some `weight` with a bad number, but really.... I'm not sure. – Aspicas Oct 08 '15 at 07:39

3 Answers3

1

Where is fault

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.2"
    android:orientation="vertical"
    android:gravity="center"
    android:background="@drawable/button_create_account_background"
    android:clickable="true"
    >
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/create_an_account"
        android:textColor="@android:color/white"
        />
</LinearLayout>

Actually Your last layout is not purely bottom side .Thats why have problem .Another problemandroid:layout_weight="0.2" .The android:layout_weight is not proper for set bottom side .

Try this

I think you should try a relative layout.If you have a relative layout that fills the whole screen you should be able to use android:layout_alignParentBottom to move the button to the bottom of the screen. Courtesy

Or

You can use LinearLayout android:weightSum Property .

What is android:weightSum in android, and how does it work?

Community
  • 1
  • 1
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
  • 1
    yes I can do that but I want the layout_weight property which is not available in RelativeLayout. Thanks. – Shaw Oct 08 '15 at 07:36
  • @user2787602 Another reason .Actually when use set ` android:layout_marginBottom="20dp"` thats why have problem .Avoid Hard coded value .You can use `android:weightSum` Property – IntelliJ Amiya Oct 08 '15 at 07:39
0

The simplest way I have found of fixing the 1dp line issue is to scale up the values you are using for the weights.

An easy way to do this is to scale each weight until there are no decimal points, so for example:

android:layout_weight="0.2"

would become

android:layout_weight"2"

Provided you apply this multiplier to each weight in your layout they should all maintain the same scale but with no line at the bottom.

I can't say for certain, but my assumption is that using smaller decimal values results in some rounding error by Android - leaving the unwanted 1dp line at the bottom of the layout.

0

I had the same problem and changing android:layout_height="match_parent" of LinearLayout to android:layout_height="fill_parent" solved the problem.

The white border was showing only on one "slide" in my application. I am not sure, but I think the image that we display can have influence on that.

Of course, changing layout_height is not what we can always do. It's rather like a work-around, not a proper solution.

Piotr Sagalara
  • 2,247
  • 3
  • 22
  • 25