虚拟键挡住PickerView,使用.setDecorView((ViewGroup)getWindow().getDecorView().findViewById(android.R.id.content))解决了遮挡的问题,但是状态栏却没有被阴影盖住,请问怎样才能既不让虚拟键挡住PickerView阴影又能够遮住状态栏?
3vpjnl9f1#
@xiaosong520
//将控件添加到decorView中rootView = (ViewGroup) layoutInflater.inflate(R.layout.layout_basepickerview, mPickerOptions.decorView, false);FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);layoutParams.bottomMargin = 120; //设置一个margin值,可根据底部导航栏的高度设置试试rootView.setLayoutParams(layoutParams);
daolsyd02#
同问,怎么解决啊!!!
7xllpg7q3#
TimePickerView pvTime = new TimePickerBuilder(context, new OnTimeSelectListener() {@OverRidepublic void onTimeSelect(Date date, View v) {}}).setDecorView(view).build();pvTime.show();
build之前setDecorView,view传入当前activity/fragment的最底层布局(父布局)
brvekthn4#
/**
通过上面方法将其设置为dialog样式,然后显示即可解决TimePickerView pickerView = getTimePickerView(pvTime);pickerView.show();
7xzttuei5#
build()之前调用setDecorView即可activity中如下
.setDecorView(activity.getWindow().getDecorView().findViewById(android.R.id.content)) .build();
Frament中类似 下面是demo中的例子:
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { mView = inflater.inflate(R.layout.fragment_test, null); return mView; } @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mFrameLayout = (FrameLayout) mView.findViewById(R.id.fragmen_fragment); } .setDecorView(mFrameLayout)//非dialog模式下,设置ViewGroup, pickerView将会添加到这个ViewGroup中
jvidinwx6#
@keke195 可尝试使用dialog方式。
qkf9rpyu7#
dialog也没用啊,这要怎么解决。。
o4tp2gmn8#
bxfogqkk9#
有什么办法解决吗
9条答案
按热度按时间3vpjnl9f1#
@xiaosong520
//将控件添加到decorView中
rootView = (ViewGroup) layoutInflater.inflate(R.layout.layout_basepickerview, mPickerOptions.decorView, false);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
layoutParams.bottomMargin = 120; //设置一个margin值,可根据底部导航栏的高度设置试试
rootView.setLayoutParams(layoutParams);
daolsyd02#
同问,怎么解决啊!!!
7xllpg7q3#
TimePickerView pvTime = new TimePickerBuilder(context, new OnTimeSelectListener() {
@OverRide
public void onTimeSelect(Date date, View v) {
}
})
.setDecorView(view).build();
pvTime.show();
build之前setDecorView,view传入当前activity/fragment的最底层布局(父布局)
brvekthn4#
/**
*/
@nonnull
private static TimePickerView getTimePickerView(TimePickerBuilder pvTime) {
pvTime.isDialog(true);// 显示为对话框样式
TimePickerView pickerView = pvTime.build();
Dialog mDialog = pickerView.getDialog();
if (mDialog != null) {
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
Gravity.BOTTOM);
params.leftMargin = 0;
params.rightMargin = 0;
pickerView.getDialogContainerLayout().setLayoutParams(params);
Window dialogWindow = mDialog.getWindow();
if (dialogWindow != null) {
dialogWindow.setWindowAnimations(R.style.picker_view_slide_anim);//修改动画样式
dialogWindow.setGravity(Gravity.BOTTOM);//改成Bottom,底部显示
dialogWindow.setDimAmount(0.3f);// 设置透明度
}
}
return pickerView;
}
通过上面方法将其设置为dialog样式,然后显示即可解决
TimePickerView pickerView = getTimePickerView(pvTime);
pickerView.show();
7xzttuei5#
build()之前调用setDecorView即可
activity中如下
Frament中类似 下面是demo中的例子:
jvidinwx6#
@keke195 可尝试使用dialog方式。
qkf9rpyu7#
dialog也没用啊,这要怎么解决。。
o4tp2gmn8#
@xiaosong520
bxfogqkk9#
有什么办法解决吗