状态栏与活动重叠

时间:2017-11-10 20:31:21

标签: java android android-layout

问题

enter image description here

状态栏与工具栏重叠。我试图设置各种属性,但它没有成功。所以现在建议我如何处理这个问题以及导致这个问题的原因。 还有一点需要注意的是,我在另一个活动中使用了透明状态栏属性。

activity_symptom.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"
tools:context="com.example.nishantsikri.microdoctor.SymptomActivity">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_symptom" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    app:srcCompat="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>

content_symptom.xml

<?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:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.nishantsikri.microdoctor.SymptomActivity"
tools:showIn="@layout/activity_symptom">


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:id="@+id/symptom1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Symptom 1" />

    <Spinner
        android:id="@+id/spinner1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:spinnerMode="dialog"
        android:layout_gravity="start|center_vertical"
        android:ellipsize="marquee"
        android:gravity="center_vertical"
        android:minHeight="48dp"
        android:paddingBottom="12dp"
        android:paddingLeft="24dp"
        android:paddingRight="24dp"
        android:paddingStart="24dp"
        android:paddingTop="12dp"/>

    <TextView
        android:id="@+id/symptom2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Symptom 2" />

    <Spinner
        android:id="@+id/spinner2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="start|center_vertical"
        android:spinnerMode="dialog"
        android:ellipsize="marquee"
        android:gravity="center_vertical"
        android:minHeight="48dp"
        android:paddingBottom="12dp"
        android:paddingLeft="24dp"
        android:paddingRight="24dp"
        android:paddingStart="24dp"
        android:paddingTop="12dp"/>

    <TextView
        android:id="@+id/symptom3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Symptom 3" />

    <Spinner
        android:id="@+id/spinner3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="start|center_vertical"
        android:spinnerMode="dialog"
        android:ellipsize="marquee"
        android:gravity="center_vertical"
        android:minHeight="48dp"
        android:paddingBottom="12dp"
        android:paddingLeft="24dp"
        android:paddingRight="24dp"
        android:paddingStart="24dp"
        android:paddingTop="12dp"/>

    <Button
        android:id="@+id/button8"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Button"
        tools:layout_editor_absoluteX="70dp"
        tools:layout_editor_absoluteY="16dp" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="TextView"
        tools:layout_editor_absoluteX="127dp"
        tools:layout_editor_absoluteY="170dp" />
</LinearLayout>

</android.support.constraint.ConstraintLayout>

styles.xml

<resources xmlns:tools="http://schemas.android.com/tools">

<!-- 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>
    <item name="android:windowTranslucentStatus" tools:targetApi="19">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="21">true</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

<style name="AppTheme.Button" parent="Widget.AppCompat.Button.Colored">
    <item name="colorControlHighlight">@color/indigo</item>
    <item name="colorButtonNormal">@color/pink</item>
    <item name="android:textColor">@color/White</item>
    <item name="android:padding">20dp</item>
</style>

//Styles for Trending Topics Content Header Text

<style name="TextAppearance.Design.CollapsingToolbar.Expanded.Shadow">
    <item name="android:shadowDy">0</item>
    <item name="android:shadowDx">0</item>
    <item name="android:shadowRadius">8</item>
    <item name="android:shadowColor">@android:color/black</item>
</style>

<style name="AppThemeNavigation" 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>

    <item name="android:textColorPrimary">@android:color/white</item>
    <item name="android:windowTranslucentStatus" tools:targetApi="19">true</item>

    <item name="android:windowContentOverlay">@null</item>
    <item name="windowActionBar">false</item>

    <item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="21">true</item>
</style>

</resources>

0 个答案:

没有答案