android - 屏幕底部的白线(LinearLayout)

标签 android android-linearlayout

我正在为我的应用程序设计登录屏幕。问题是我在每台设备和模拟器的屏幕底部都有一条白线。 您可以在此处检查输出: http://www.imgur.com/cTMu4Ap 这是我的布局 xml 代码。请注意,我使用 layout_weight 属性在所有设备之间实现相等的空间。

<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>

最佳答案

错在哪里

<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>

实际上你的最后一个布局不是纯粹的底部。这就是为什么有问题。另一个问题android:layout_weight="0.2"android:layout_weight 不适合设置底部。

试试这个

我认为你应该尝试相对布局。如果你有一个填满整个屏幕的相对布局,你应该能够使用 android:layout_alignParentBottom将按钮移动到屏幕底部。 Courtesy

或者

您可以使用 LinearLayout android:weightSum属性(property)。

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

关于android - 屏幕底部的白线(LinearLayout),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33009143/

相关文章:

android - 使用 phonegap 在 android 中关闭 Bootstrap 模态

android - Android中具有透明背景的ImageButton

android:load svg file from web and show it on image view

android-layout - 如何强制我的复选框文本不换行?

android - 以编程方式将 View 添加到 LinearLayout

安卓动画问题

java - 如何从 AutoCompleteTextView 中选取文本并将其显示在 ListView 中?

android - 在 Android 中存储 Google Cloud Platform 服务帐户私钥的位置

java - 如何通过 Firebase 从用户向用户发送直接消息?

android - 在 ScrollView 中动态添加 View 到 RelativeLayout