用抽屉布局为另一种布局增添色彩

时间:2019-02-19 07:49:13

标签: java android navigation navigation-drawer

问候我的程序员,

我猜想我很容易,但是我仍然不知道为什么会导致这种行为。

所以场景是这样的:我有通过服务播放音乐的应用程序,并且在底部有一个迷你播放器,通过这种方式我夸大了主布局。

如果我不使用迷你播放器给版式增加布局,则可以正常使用抽屉中的方法(菜单项)(它将我带到想要的目的地并完美地触发滑动操作),一旦我开始播放音乐,就对版式进行了修改,因此我可以显示播放器,我可以用抽屉做到这一点:

  1. 我可以通过滑动和汉堡按钮打开它
  2. 我可以通过滑动和汉堡按钮打开它
  3. 我无法通过左右滑动将其关闭
  4. 方法不能在抽屉内使用

有什么想法为什么会把它弄乱?

P.S 在主布局上,我在父视图上使用Coordinator Layout,所以我可以使用浮动按钮

*****编辑:这里是屏幕******

    <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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/cili_test"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.example.android.listenyo_41.MainActivity"
    android:background="@color/white">
    <!-- Loading indicator is only shown before the first load -->


<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="com.example.android.listenyo_41.MainActivity"
    android:id="@+id/cili_test2"
    android:background="@color/black"
    >

    <!-- Loading indicator is only shown before the first load -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/nesto_glupo"
        android:orientation="vertical"

        >
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="@color/black">

                <ImageButton     
                    />

                <android.support.v7.widget.Toolbar      
                    />

                <com.miguelcatalan.materialsearchview.MaterialSearchView
                    /> 
                    </RelativeLayout>
      <ListView

            />
        <RelativeLayout

            >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_alignParentTop="true"
                android:orientation="vertical"
                android:background="@color/black"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="5dp"
                android:id="@+id/test_fade"
                >

                <Button

                    />

                <android.support.v4.widget.SwipeRefreshLayout
                    android:id="@+id/activity_main_swipe_refresh_layout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                    <ListView

                        />
                </android.support.v4.widget.SwipeRefreshLayout>


                <!-- Empty view is only visible when the list has no items. -->

            </LinearLayout>
        </RelativeLayout>
    </LinearLayout>
    <TextView

        />
    <ProgressBar

        />

</RelativeLayout>

    <!-- Container for contents of drawer - use NavigationView to make configuration easier -->
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/drawer_view"
app:headerLayout="@layout/nav_header"

    app:itemIconTint="@color/white"
    android:background="@color/black"
    app:itemTextColor="@color/white"
    />
    </android.support.v4.widget.DrawerLayout>















            <ProgressBar
                android:id="@+id/picasso_progress"
                style="@android:style/Widget.Holo.Light.ProgressBar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:layout_gravity="center"
                android:visibility="gone" />

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:background="#75d9534f"
                android:id="@+id/crvena_traka"

                >


                <RelativeLayout
                    android:id="@+id/songName_layout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:visibility="gone">

                    <SeekBar
                        android:id="@+id/seekBar"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="10dp"
                        android:layout_marginRight="135dp"
                        android:layout_marginTop="5dp"
                        android:paddingEnd="6dp"
                        android:paddingLeft="6dp"
                        android:paddingRight="6dp"
                        android:paddingStart="6dp"
                        android:progressDrawable="@drawable/progress_drawable"
                        android:thumbTint="@color/black"
                        android:visibility="gone"

                        />


                    <TextView
                        android:id="@+id/songDuration"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:layout_below="@id/seekBar"
                        android:layout_gravity="center"
                        android:layout_marginBottom="5dp"
                        android:layout_marginLeft="15dp"
                        android:layout_marginRight="140dp"
                        android:layout_marginTop="2dp"
                        android:text="00:00:00"
                        android:textColor="@color/white"
                        android:textStyle="bold"
                        android:visibility="gone"
                        />

                    <com.example.android.listenyo_41.ScrollTextView
                        android:id="@+id/songName"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_below="@id/seekBar"
                        android:layout_marginBottom="5dp"
                        android:layout_marginLeft="15dp"
                        android:layout_marginTop="2dp"
                        android:layout_toLeftOf="@id/songDuration"

                        android:textColor="@color/white"
                        android:textSize="14sp"
                        android:textStyle="bold"
                        android:visibility="gone"

                        />



                </RelativeLayout>


            </RelativeLayout>


        </RelativeLayout>

        <TextView
            android:id="@+id/btn_lay_textView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="7dp"
            android:text="Buffering"
            android:textAlignment="center"
            android:textColor="@color/gray"
            android:textSize="16sp"
            android:textStyle="bold"
            android:visibility="gone"

            android:layout_marginRight="5dp"
            android:layout_marginLeft="5dp"
            />
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_below="@id/player_controler"

            android:layout_weight="2">

            <ProgressBar
                android:id="@+id/loading_indicator2"
                style="?android:attr/progressBarStyleLarge"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="100dp"
                android:indeterminateDrawable="@drawable/my_border4"
                android:visibility="gone" />




            <RelativeLayout
                android:id="@+id/player_controler2"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:layout_marginTop="5dp"
                android:background="@color/black"
                android:visibility="visible">


                <LinearLayout

                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_margin="5dp"
                    android:layout_marginTop="20dp"
                    android:orientation="vertical"

                    >


                    <android.support.v4.widget.SwipeRefreshLayout
                        android:id="@+id/activity_main_swipe_refresh_layout"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@color/black">

                        <ListView
                            android:id="@+id/list"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:background="@color/black"
                            android:choiceMode="singleChoice"
                            android:divider="@null"
                            android:dividerHeight="5dp"
                            android:orientation="horizontal"


                            />
                    </android.support.v4.widget.SwipeRefreshLayout>


                </LinearLayout>


            </RelativeLayout>
        </RelativeLayout>


    </LinearLayout>


    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/activity_main_swipe_refresh_layout2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="100dp"
        android:visibility="gone">

        <TextView
            android:id="@+id/empty_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_marginLeft="50dp"
            android:layout_marginRight="50dp"
            android:gravity="center"
            android:textAppearance="?android:textAppearanceMedium"

            />

    </android.support.v4.widget.SwipeRefreshLayout>

    </FrameLayout>

        <!-- Container for contents of drawer - use NavigationView to make configuration easier -->
        <android.support.design.widget.NavigationView
            android:id="@+id/nav_view"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:fitsSystemWindows="true"
            app:menu="@menu/drawer_view"
            app:headerLayout="@layout/nav_header"
            app:itemIconTint="@color/white"
            android:background="@color/black"
            app:itemTextColor="@color/white"
            />
    </android.support.v4.widget.DrawerLayout>


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

还有迷你播放器

 <?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"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:id="@+id/play_test"
    android:visibility="visible"
    >





    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="60dp"
        android:layout_alignParentBottom="true"
        android:background="@color/myColor"
        android:elevation="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginBottom="5dp"
        android:id="@+id/play_lay"
        >


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:orientation="horizontal"
        android:background="@drawable/bl_tran_grad"
        >



        <RelativeLayout

            android:id="@+id/icon_layout"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_margin="5dp"
            android:layout_marginTop="5dp"
            android:layout_marginBottom="10dp"
            android:layout_weight="1"
            android:onClick="player"
            >

            <ProgressBar
                style="@android:style/Widget.Holo.Light.ProgressBar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_centerInParent="true"
                android:visibility="gone"

                android:id="@+id/picasso_progress2"
                />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="gone"
                android:layout_gravity="center"
                android:id="@+id/error2"
                android:text="Error loading picture"
                android:textColor="@color/black"
                android:textSize="13sp"

                android:textStyle="bold"
                android:textAlignment="center"
                android:layout_centerInParent="true"

                />

        <ImageView
            android:id="@+id/player_img"
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:layout_centerInParent="true"
            android:scaleType="centerCrop"
            >
        </ImageView>



        </RelativeLayout>

        <RelativeLayout

            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="2"
            android:layout_margin="5dp"
            android:onClick="player"
            >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:maxLines="2"
            android:id="@+id/songName2"
            android:textSize="14sp"
            android:layout_centerVertical="true"
            android:textColor="@color/white"

            android:textStyle="bold"
            />
        </RelativeLayout>


        <RelativeLayout

            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:onClick="player_2_pause"
            >

        <ImageView
            android:layout_width="50dp"
            android:layout_height="35dp"
            android:layout_centerInParent="true"
            android:src="@drawable/ic_launcher"
            android:onClick="player_2_resume"
            android:visibility="invisible"
            android:id="@+id/player_2_resume"

            />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Buffering"
                android:textColor="@color/white"
                android:layout_centerInParent="true"
                android:textSize="14sp"
                android:visibility="visible"
                android:id="@+id/buffering"
                />


        <ImageView
            android:layout_width="50dp"
            android:layout_height="35dp"
            android:src="@drawable/pause2"
            android:onClick="player_2_pause"
            android:visibility="invisible"
            android:id="@+id/player_2_pause"
            android:layout_centerInParent="true"
            />
        </RelativeLayout>

    </LinearLayout>
    </RelativeLayout>

    <SeekBar
        android:padding="0dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:id="@+id/seekBar_player2"
        android:layout_width="match_parent"
        android:layout_height="4.0dp"
        android:layout_above="@id/play_lay"
        android:background="#80000000"
        android:maxHeight="5dp"
        android:minHeight="4dp"
        android:progressDrawable="@drawable/progress_drawable"
        android:max="10"
        android:thumb="@color/white"
        android:paddingStart="0dp"
        android:paddingEnd="0dp"
        android:paddingLeft="0dp"
        android:paddingRight="0dp" />

</RelativeLayout>






When player active[1]
without player drawer[2]
both[3]




[1]: https://i.stack.imgur.com/gD0BY.jpg
  [2]: https://i.stack.imgur.com/0zcYP.jpg
  [3]: https://i.stack.imgur.com/qFY6q.jpg

0 个答案:

没有答案