Android约束布局白条位于顶部

时间:2019-05-01 19:09:27

标签: android android-layout

我正在为我正在从事的项目开发Android应用程序。

我已经实现了功能并开始设计布局。我遇到了一个似乎找不到或无法找到在线解决方案的问题。我的约束布局出于未知原因在顶部带有白色条。

我曾尝试将布局转换为线性,但该条似乎仍然存在。我错过的东西真的很明显还是这是一个错误?

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/gradient"
    tools:context=".Login">
<EditText
    android:id="@+id/registerEmailField"
    android:layout_width="371dp"
    android:layout_height="40dp"
    android:layout_marginTop="8dp"
    android:layout_marginBottom="8dp"
    android:background="@drawable/rounded_white"
    android:ems="10"
    android:hint="@string/email"
    android:importantForAutofill="no"
    android:inputType="textEmailAddress"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.469"
    tools:targetApi="o" />

<EditText
    android:id="@+id/loginPasswordField"
    android:layout_width="371dp"
    android:layout_height="43dp"
    android:autofillHints=""
    android:background="@drawable/rounded_white"
    android:ems="10"
    android:hint="@string/password"
    android:inputType="textPassword"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.561"
    tools:targetApi="o" />

<ImageView
    android:id="@+id/PicShare"
    android:layout_width="196dp"
    android:layout_height="67dp"
    android:layout_marginTop="8dp"
    android:layout_marginBottom="8dp"
    android:contentDescription="@string/the_picshare_logo"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.497"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.348"
    app:srcCompat="@drawable/pic_share" />

<Button
    android:id="@+id/loginButton"
    android:layout_width="371dp"
    android:layout_height="45dp"
    android:background="@drawable/rounded_blue"
    android:text="@string/login"
    android:textColor="#FFFFFF"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.665" />

<Button
    android:id="@+id/navigate_to_register"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/transparent"
    android:text="@string/not_registered_sign_up"
    android:textColor="#FFFFFF"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.497"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.752" />

Layout debug

Application when built

<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>

1 个答案:

答案 0 :(得分:2)

您应该在$childpages = get_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0' ); if ( $childpages ) { $string = '<nav class="sidenav"><ul><li><a href="'.get_permalink($post->post_parent).'">'.get_the_title($post->post_parent).'</a></li>' foreach( $childpages as $page ) { $string .= '<li><a href="' . get_permalink($page->ID) . '">' . get_post_meta($page->ID, 'sidebar_title', true) . '</a></li>'; } $string .= '</ul></nav>'; return $string; } 中检查主题属性,您可以像这样values/styles.xml那样设置主题。或者您可以像这样Theme.Black.NoTitleBar.Fullscreen

设置标题属性

在您的styles.xml中

<item name="android:windowNoTitle">true</item>

在manifest.xml中

<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
</style>