Closed tczyb closed 8 years ago
PanelLayout是一个Layout(ViewGroup),你把 表情面板与功能面板都放到Panel中,切换的时候,都显示PanelLayout,然后显示 不同的面板(表情/功能)。
KPSwitchConflictUtil.attach(panel_root, 功能, et_input) KPSwitchConflictUtil.attach(panel_root, 表情, et_input) 是这样吗
哦。你是这个问题。
不能这样attach。如果是这个情况。你先这样封装一个使用:
// 使用这个attach.
public static void attach(final View panelLayout,
final View functionPanelBtn,
final View functionPanelViewGroup,
final View emojiPanelBtn,
final View emojiPanelViewGroup,
final View focusView,
final SwitchClickListener switchClickListener) {
final Activity activity = (Activity) panelLayout.getContext();
bindSubPanel(functionPanelBtn, functionPanelViewGroup, new View[]{emojiPanelViewGroup},
focusView, panelLayout, switchClickListener);
bindSubPanel(emojiPanelBtn, emojiPanelViewGroup, new View[]{functionPanelViewGroup},
focusView, panelLayout, switchClickListener);
if (KPSwitchConflictUtil.isHandleByPlaceholder(activity)) {
focusView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
/**
* Show the fake empty keyboard-same-height panel to fix the conflict when
* keyboard going to show.
* @see KPSwitchConflictUtil#showKeyboard(View, View)
*/
panelLayout.setVisibility(View.INVISIBLE);
}
return false;
}
});
}
}
public static void bindSubPanel(final View triggerBtn, final View boundTriggerSubPanel,
final View[] otherSubPanelArray,
final View focusView, final View panelLayout,
final SwitchClickListener switchClickListener) {
triggerBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Boolean switchToPanel = null;
if (panelLayout.getVisibility() == View.VISIBLE) {
// panel is visible.
if (boundTriggerSubPanel.getVisibility() == View.VISIBLE) {
// bound-trigger panel is visible.
// to show keyboard.
KPSwitchConflictUtil.showKeyboard(panelLayout, focusView);
switchToPanel = false;
} else {
// bound-trigger panel is invisible.
// to show bound-trigger panel.
for (View otherSubPanel : otherSubPanelArray) {
otherSubPanel.setVisibility(View.GONE);
}
boundTriggerSubPanel.setVisibility(View.VISIBLE);
}
} else {
// panel is gone.
// to show panel.
KPSwitchConflictUtil.showPanel(panelLayout);
switchToPanel = true;
// to show bound-trigger panel.
for (View otherSubPanel : otherSubPanelArray) {
otherSubPanel.setVisibility(View.GONE);
}
boundTriggerSubPanel.setVisibility(View.VISIBLE);
}
if (switchClickListener != null && switchToPanel != null && switchToPanel) {
switchClickListener.onClickSwitch(switchToPanel);
}
}
});
}
下个版本我会封装进去的。
我试了这种方案 可是还回闪动;希望楼主更新一下吧
@chenlong0525 你可以clone demo下来跑跑看。然后对比下。demo上面是没有问题的。就是多个面板。
我现在就是添加表情面板 可是按照你上述的方式进行添加;并不可以
@chenlong0525 这个和是用做什么的面板没有关系(之前在微信时,功能面板与表情面板也是这么做的):
这边选上"There are several sub-panels in on page":
你好。请问下一下,如果 public static boolean isHandleByPlaceholder(boolean isFullScreen, boolean isTranslucentStatus, boolean isFitsSystem) { return isFullScreen || (isTranslucentStatus && !isFitsSystem); } return false的话,就会导致onKeyboardShowing回调不能响应,这样如何知道键盘的状态呢
我想再添加一个按钮弹出表情面板,该如何做?