首页 > 解决方案 > 每当我尝试打开通知快门时,布局总是会波动,或者你能参考一些博客吗

问题描述

https://i.stack.imgur.com/VoBbj.gif 布局表现得很尴尬,我不知道为什么如果有人可以帮助我,那就太好了。每当我尝试打开通知面板时,布局都会改变其位置。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    tools:context=".MainActivity"
    android:orientation="vertical"
    android:background="@color/dark"
    >

    <RelativeLayout
        android:id="@+id/top_card"
        android:background="@color/lightDark"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="10dp"
        >
        <LinearLayout
            android:id="@+id/search"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="20dp"
            android:layout_marginTop="20dp"
            android:background="@drawable/round"
            android:layout_alignParentStart="true">
            <ImageView
                android:layout_width="30dp"
                android:layout_height="35dp"
                android:src="@drawable/ic_about"
                android:id="@+id/info"
                android:contentDescription="@string/todo8">

            </ImageView>
        </LinearLayout>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/musify"
            android:textStyle="bold"
            android:layout_toEndOf="@+id/search"
            android:layout_toStartOf="@+id/menu_bar"
            android:textSize="26sp"
            android:textColor="@color/day"
            android:textAlignment="center"
            android:layout_centerInParent="true"
            />
        <LinearLayout
            android:id="@+id/menu_bar"
            android:layout_alignParentEnd="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="20dp"
            android:layout_marginTop="20dp"
            android:layout_marginLeft="20dp"
            android:background="@drawable/round"
            android:layout_marginRight="20dp">
            <ImageView
                android:layout_width="30dp"
                android:layout_height="35dp"
                android:id="@+id/menu"
                android:src="@drawable/ic_menu"
                android:contentDescription="@string/todo5" />
        </LinearLayout>
    </RelativeLayout>

    <androidx.recyclerview.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/bottom_card"
        android:layout_below="@+id/top_card"
        android:id="@+id/music_recycler_view"
        >

    </androidx.recyclerview.widget.RecyclerView>

    <LinearLayout
        android:id="@+id/bottom_card"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_alignParentBottom="true"
        android:paddingTop="15dp"
        android:background="@drawable/round"
        >
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            >
            <TextView
                android:id="@+id/musicbar_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="18sp"
                android:layout_centerVertical="true"
                android:textColor="@color/day"
                android:layout_marginBottom="10dp"
                android:layout_marginStart="10dp"
                />
        </RelativeLayout>
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="5dp"
            >

            <TextView
                android:id="@+id/musicbar_artist"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="16sp"
                android:layout_centerVertical="true"
                android:textColor="@color/day"
                android:paddingBottom="5dp"
                android:layout_marginStart="10dp" />
        </RelativeLayout>
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/round"
            >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/_0_00"
                android:id="@+id/start_time"
                android:textSize="15sp"
                android:layout_centerVertical="true"
                android:textColor="@color/day"
                android:background="@color/lightDark"
                android:layout_marginStart="5dp" />
            <SeekBar
                android:id="@+id/playerseekbar"
                android:layout_centerVertical="true"
                android:progressDrawable="@drawable/custom_seekbar"
                android:progress="0"
                android:max="100"
                android:thumb="@drawable/custom_thumb"
                android:layout_toEndOf="@+id/start_time"
                android:layout_toStartOf="@+id/end_time"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
            <TextView
                android:layout_marginEnd="10dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/end_time"
                android:text="@string/_0_00"
                android:textSize="15sp"
                android:layout_centerVertical="true"
                android:textColor="@color/day"
                android:layout_alignParentEnd="true"/>

        </RelativeLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_gravity="center"
            android:gravity="center">

            <ImageView
                android:id="@+id/prev"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:src="@drawable/ic_baseline_skip_previous_24"
                android:background="@drawable/round_icon"
                android:padding="10dp"
                android:contentDescription="@string/todo6" />

            <androidx.cardview.widget.CardView
                android:id="@+id/play_pause_card"
                android:layout_width="90dp"
                android:layout_height="100dp"
                app:cardBackgroundColor="@color/card"
                app:cardCornerRadius="20dp"
                app:cardElevation="10dp"
                app:cardUseCompatPadding="true"
                android:outlineAmbientShadowColor="@color/black"
                android:outlineSpotShadowColor="@color/black"
                >
                <ImageView
                    android:id="@+id/play_pause_button"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:src="@drawable/ic_baseline_play_arrow_24"
                    android:contentDescription="@string/todo1" />
            </androidx.cardview.widget.CardView>
            <ImageView
                android:id="@+id/next"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:src="@drawable/ic_baseline_skip_next_24"
                android:background="@drawable/round_icon"
                android:padding="10dp"
                android:contentDescription="@string/todo7" />

        </LinearLayout>

    </LinearLayout>
</RelativeLayout>

帮帮我,我不知道发生了什么!如果有人能给我一些关于底牌的想法,让它看起来不错,那就太好了。

标签: javaandroidxmlandroid-studioandroid-layout

解决方案


 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

我在 onCreate() 方法中添加了它,并且它起作用了。


推荐阅读