Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DrawerLayout下当用两个FrameLayout时setColorForDrawerLayout()函数会无效,无法变色 #15

Closed
chenjj2048 opened this issue Apr 10, 2016 · 0 comments

Comments

@chenjj2048
Copy link

用Fragment替换DrawerLayout下的content和drawer时,如果下面是FrameLayout就没办法换颜色,需替换成LinearLayout才能变色
像下面这样才行,如果是FrameLayout或RelativeLayout就会错乱

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    android:fitsSystemWindows="true">

    <LinearLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" />

    <LinearLayout
        android:id="@+id/drawer"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:orientation="vertical" />
</android.support.v4.widget.DrawerLayout>

下面函数只做了LinearLayout的判断,木有FrameLayout等的判断

public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, int color, int statusBarAlpha)
.....
// 内容布局不是 LinearLayout 时,设置padding top
        if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
            contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
        }
.....
@chenjj2048 chenjj2048 reopened this Jun 7, 2016
@laobie laobie reopened this Jun 7, 2016
@laobie laobie closed this as completed Aug 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants