【发布时间】:2016-10-27 19:04:26
【问题描述】:
每当我打开导航抽屉框架布局内容时,我什至尝试将框架的颜色设置为白色
main_activity.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/drawer_layout"
tools:context="com.example.sumanravi.knowmycity.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/content_layout"
android:background="@color/white">
</FrameLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:orientation="vertical">
<ListView
android:layout_width="200dp"
android:layout_height="match_parent"
android:id="@+id/navList"
android:choiceMode="singleChoice">
</ListView>
</LinearLayout>
【问题讨论】:
-
将 background 颜色设置为白色仍将显示任何视图的内容。如果要隐藏视图的内容,应使用
View#setVisibility(int)将其可见性设置为View.GONE或View.VISIBLE -
这很好用,但是无论何时打开或关闭抽屉,都需要一些时间才能使内容可见和不可见,请帮我解决这个问题
-
好吧,我现在就完整回答:)
-
顺便说一句,如果它对您有用,您应该接受答案,以便我们可以关闭问题。