Skip to content

Commit 4d5affe

Browse files
committed
Trying load it on top of everything
1 parent 3f10938 commit 4d5affe

File tree

1 file changed

+50
-9
lines changed

1 file changed

+50
-9
lines changed

pickerview/src/main/java/com/bigkoo/pickerview/view/BasePickerView.java

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,63 @@ public void onClick(View view) {
8181
} else {
8282
//如果只是要显示在屏幕的下方
8383
//decorView是activity的根View,包含 contentView 和 titleView
84+
// if (mPickerOptions.decorView == null) {
85+
// if (context instanceof Activity) {
86+
// mPickerOptions.decorView = (ViewGroup) ((Activity) context).getWindow().getDecorView();
87+
//
88+
// ((Activity) context).getWindow().
89+
// } else if (context instanceof ContextThemeWrapper && ((ContextThemeWrapper) context).getBaseContext() instanceof Activity) {
90+
// mPickerOptions.decorView = (ViewGroup) ((Activity) ((ContextThemeWrapper) context).getBaseContext()).getWindow().getDecorView();
91+
// }
92+
// }
93+
// //将控件添加到decorView中
94+
// rootView = (ViewGroup) layoutInflater.inflate(R.layout.layout_basepickerview, mPickerOptions.decorView, false);
95+
// rootView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
96+
// if (mPickerOptions.outSideColor != -1) {
97+
// rootView.setBackgroundColor(mPickerOptions.outSideColor);
98+
// }
99+
// //这个是真正要加载时间选取器的父布局
100+
// contentContainer = (ViewGroup) rootView.findViewById(R.id.content_container);
101+
// contentContainer.setLayoutParams(params);
102+
84103
if (mPickerOptions.decorView == null) {
85104
if (context instanceof Activity) {
105+
// Get the decor view of the current activity and use it as the decorView for your picker
86106
mPickerOptions.decorView = (ViewGroup) ((Activity) context).getWindow().getDecorView();
107+
108+
// Add your rootView to the decor view of the activity
109+
rootView = (ViewGroup) layoutInflater.inflate(R.layout.layout_basepickerview, mPickerOptions.decorView, false);
110+
rootView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
111+
if (mPickerOptions.outSideColor != -1) {
112+
rootView.setBackgroundColor(mPickerOptions.outSideColor);
113+
}
114+
115+
// Find the content container within your rootView
116+
contentContainer = (ViewGroup) rootView.findViewById(R.id.content_container);
117+
contentContainer.setLayoutParams(params);
118+
119+
// Add the rootView to the decor view of the activity
120+
((ViewGroup) ((Activity) context).getWindow().getDecorView()).addView(rootView);
87121
} else if (context instanceof ContextThemeWrapper && ((ContextThemeWrapper) context).getBaseContext() instanceof Activity) {
122+
// If the context is a ContextThemeWrapper, get the base context which should be the activity
88123
mPickerOptions.decorView = (ViewGroup) ((Activity) ((ContextThemeWrapper) context).getBaseContext()).getWindow().getDecorView();
124+
125+
// Add your rootView to the decor view of the activity
126+
rootView = (ViewGroup) layoutInflater.inflate(R.layout.layout_basepickerview, mPickerOptions.decorView, false);
127+
rootView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
128+
if (mPickerOptions.outSideColor != -1) {
129+
rootView.setBackgroundColor(mPickerOptions.outSideColor);
130+
}
131+
132+
// Find the content container within your rootView
133+
contentContainer = (ViewGroup) rootView.findViewById(R.id.content_container);
134+
contentContainer.setLayoutParams(params);
135+
136+
// Add the rootView to the decor view of the activity
137+
((ViewGroup) ((Activity) context).getWindow().getDecorView()).addView(rootView);
89138
}
90139
}
91-
//将控件添加到decorView中
92-
rootView = (ViewGroup) layoutInflater.inflate(R.layout.layout_basepickerview, mPickerOptions.decorView, false);
93-
rootView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
94-
if (mPickerOptions.outSideColor != -1) {
95-
rootView.setBackgroundColor(mPickerOptions.outSideColor);
96-
}
97-
//这个是真正要加载时间选取器的父布局
98-
contentContainer = (ViewGroup) rootView.findViewById(R.id.content_container);
99-
contentContainer.setLayoutParams(params);
140+
100141
}
101142
setKeyBackCancelable(true);
102143
}

0 commit comments

Comments
 (0)