我可以尝试在AOSP键盘中添加选项卡布局,但不能单击选项卡,并且whatsapp编辑文本也隐藏在选项卡后面,所以请帮助我如何在AOSP键盘中添加选项卡功能?
谢谢
使键盘如下图所示。
代码
//Added new
mSearchView = (SearchView) mCurrentInputView.findViewById(R.id.view_search_view);
mSickersView = (StickersView) mCurrentInputView.findViewById(R.id.stickers_view);
slideUpAnimation = AnimationUtils.loadAnimation(mThemeContext, R.anim.slide_up_animation);
slideDownAnimation = AnimationUtils.loadAnimation(mThemeContext, R.anim.slide_down_animation);
mTabDisplayKbView = mCurrentInputView.findViewById(R.id.tab_display_kbview);
mTabDisplayKbView.setVisibility(View.GONE);
mTab0 = mCurrentInputView.findViewById(R.id.tab_0);
mTab1 = mCurrentInputView.findViewById(R.id.tab_1);
mTab2 = mCurrentInputView.findViewById(R.id.tab_2);
mTab3 = mCurrentInputView.findViewById(R.id.tab_3);
mTab4 = mCurrentInputView.findViewById(R.id.tab_4);
mTab5 = mCurrentInputView.findViewById(R.id.tab_5);
mTab6 = mCurrentInputView.findViewById(R.id.tab_6);
mTabSwitchKb = mCurrentInputView.findViewById(R.id.tab_switch_kb);
final LinearLayout mllMain = mCurrentInputView.findViewById(R.id.ll_main);
setSelect("");
mTab0.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!mTab0.isSelected()) {
mTabDisplayKbView.setVisibility(View.VISIBLE);
if (mSickersView.getVisibility() == View.INVISIBLE) {
mSickersView.startAnimation(slideUpAnimation);
}
mSickersView.setVisibility(View.VISIBLE);
mKeyboardView.setVisibility(View.VISIBLE);
// mKeyboardView.startAnimation(slideDownAnimation);
setSelect("0");
} else {
// mKeyboardView.startAnimation(slideUpAnimation);
mTabDisplayKbView.setVisibility(View.GONE);
mSickersView.setVisibility(View.INVISIBLE);
mKeyboardView.setVisibility(View.VISIBLE);
setSelect("");
mSickersView.startAnimation(slideDownAnimation);
}
}
});
mTab1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!mTab1.isSelected()) {
mTabDisplayKbView.setVisibility(View.VISIBLE);
if (mSickersView.getVisibility() == View.INVISIBLE) {
mSickersView.startAnimation(slideUpAnimation);
}
// mKeyboardView.startAnimation(slideDownAnimation);
mSickersView.setVisibility(View.VISIBLE);
mKeyboardView.setVisibility(View.VISIBLE);
setSelect("1");
} else {
mTabDisplayKbView.setVisibility(View.GONE);
// mKeyboardView.startAnimation(slideUpAnimation);
mSickersView.setVisibility(View.INVISIBLE);
mKeyboardView.setVisibility(View.VISIBLE);
setSelect("");
mSickersView.startAnimation(slideDownAnimation);
}
}
});
mTab2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!mTab2.isSelected()) {
mTabDisplayKbView.setVisibility(View.VISIBLE);
if (mSickersView.getVisibility() == View.INVISIBLE) {
mSickersView.startAnimation(slideUpAnimation);
}
// mKeyboardView.startAnimation(slideDownAnimation);
mSickersView.setVisibility(View.VISIBLE);
mKeyboardView.setVisibility(View.VISIBLE);
setSelect("2");
} else {
mTabDisplayKbView.setVisibility(View.GONE);
// mKeyboardView.startAnimation(slideUpAnimation);
mSickersView.setVisibility(View.INVISIBLE);
mKeyboardView.setVisibility(View.VISIBLE);
setSelect("");
mSickersView.startAnimation(slideDownAnimation);
}
}
});
mTab3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!mTab3.isSelected()) {
mTabDisplayKbView.setVisibility(View.VISIBLE);
if (mSickersView.getVisibility() == View.INVISIBLE) {
mSickersView.startAnimation(slideUpAnimation);
}
// mKeyboardView.startAnimation(slideDownAnimation);
mSickersView.setVisibility(View.VISIBLE);
mKeyboardView.setVisibility(View.VISIBLE);
setSelect("3");
} else {
mTabDisplayKbView.setVisibility(View.GONE);
// mKeyboardView.startAnimation(slideUpAnimation);
mSickersView.setVisibility(View.INVISIBLE);
mKeyboardView.setVisibility(View.VISIBLE);
setSelect("");
mSickersView.startAnimation(slideDownAnimation);
}
}
});
mTab4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!mTab4.isSelected()) {
mTabDisplayKbView.setVisibility(View.VISIBLE);
if (mSickersView.getVisibility() == View.INVISIBLE) {
mSickersView.startAnimation(slideUpAnimation);
}
// mKeyboardView.startAnimation(slideDownAnimation);
mSickersView.setVisibility(View.VISIBLE);
mKeyboardView.setVisibility(View.VISIBLE);
setSelect("4");
} else {
mTabDisplayKbView.setVisibility(View.GONE);
// mKeyboardView.startAnimation(slideUpAnimation);
mSickersView.setVisibility(View.INVISIBLE);
mKeyboardView.setVisibility(View.VISIBLE);
setSelect("");
mSickersView.startAnimation(slideDownAnimation);
}
}
});
mTab5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!mTab5.isSelected()) {
mTabDisplayKbView.setVisibility(View.VISIBLE);
if (mSickersView.getVisibility() == View.INVISIBLE) {
mSickersView.startAnimation(slideUpAnimation);
}
// mKeyboardView.startAnimation(slideDownAnimation);
mSickersView.setVisibility(View.VISIBLE);
mKeyboardView.setVisibility(View.VISIBLE);
setSelect("5");
} else {
mTabDisplayKbView.setVisibility(View.GONE);
// mKeyboardView.startAnimation(slideUpAnimation);
mSickersView.setVisibility(View.INVISIBLE);
mKeyboardView.setVisibility(View.VISIBLE);
setSelect("");
mSickersView.startAnimation(slideDownAnimation);
}
}
});
mTab6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!mTab6.isSelected()) {
mTabDisplayKbView.setVisibility(View.VISIBLE);
if (mSickersView.getVisibility() == View.INVISIBLE) {
mSickersView.startAnimation(slideUpAnimation);
}
// mKeyboardView.startAnimation(slideDownAnimation);
mSickersView.setVisibility(View.VISIBLE);
mKeyboardView.setVisibility(View.VISIBLE);
setSelect("6");
} else {
mTabDisplayKbView.setVisibility(View.GONE);
// mKeyboardView.startAnimation(slideUpAnimation);
mSickersView.setVisibility(View.INVISIBLE);
mKeyboardView.setVisibility(View.VISIBLE);
setSelect("");
mSickersView.startAnimation(slideDownAnimation);
}
}
});
mTabDisplayKbView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// mKeyboardView.startAnimation(slideUpAnimation);
mTabDisplayKbView.setVisibility(View.GONE);
mSickersView.setVisibility(View.INVISIBLE);
mKeyboardView.setVisibility(View.VISIBLE);
setSelect("");
mSickersView.startAnimation(slideDownAnimation);
}
});
return mCurrentInputView;
}
private void setSelect(String mPosition) {
if (mPosition.equalsIgnoreCase("0")) {
mTab0.setSelected(true);
mTab1.setSelected(false);
mTab2.setSelected(false);
mTab3.setSelected(false);
mTab4.setSelected(false);
mTab5.setSelected(false);
mTab6.setSelected(false);
setBackgroundTint("0");
} else if (mPosition.equalsIgnoreCase("1")) {
mTab0.setSelected(false);
mTab1.setSelected(true);
mTab2.setSelected(false);
mTab3.setSelected(false);
mTab4.setSelected(false);
mTab5.setSelected(false);
mTab6.setSelected(false);
setBackgroundTint("1");
} else if (mPosition.equalsIgnoreCase("2")) {
mTab0.setSelected(false);
mTab1.setSelected(false);
mTab2.setSelected(true);
mTab3.setSelected(false);
mTab4.setSelected(false);
mTab5.setSelected(false);
mTab6.setSelected(false);
setBackgroundTint("2");
} else if (mPosition.equalsIgnoreCase("3")) {
mTab0.setSelected(false);
mTab1.setSelected(false);
mTab2.setSelected(false);
mTab3.setSelected(true);
mTab4.setSelected(false);
mTab5.setSelected(false);
mTab6.setSelected(false);
setBackgroundTint("3");
} else if (mPosition.equalsIgnoreCase("4")) {
mTab0.setSelected(false);
mTab1.setSelected(false);
mTab2.setSelected(false);
mTab3.setSelected(false);
mTab4.setSelected(true);
mTab5.setSelected(false);
mTab6.setSelected(false);
setBackgroundTint("4");
} else if (mPosition.equalsIgnoreCase("5")) {
mTab0.setSelected(false);
mTab1.setSelected(false);
mTab2.setSelected(false);
mTab3.setSelected(false);
mTab4.setSelected(false);
mTab5.setSelected(true);
mTab6.setSelected(false);
setBackgroundTint("5");
} else if (mPosition.equalsIgnoreCase("6")) {
mTab0.setSelected(false);
mTab1.setSelected(false);
mTab2.setSelected(false);
mTab3.setSelected(false);
mTab4.setSelected(false);
mTab5.setSelected(false);
mTab6.setSelected(true);
setBackgroundTint("6");
} else {
mTab0.setSelected(false);
mTab1.setSelected(false);
mTab2.setSelected(false);
mTab3.setSelected(false);
mTab4.setSelected(false);
mTab5.setSelected(false);
mTab6.setSelected(false);
setBackgroundTint("");
}
}
private void setBackgroundTint(String mPosition) {
if (mPosition.equalsIgnoreCase("0")) {
mTab0.setColorFilter(mThemeContext.getResources().getColor(R.color.yellow));
mTab1.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab2.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab3.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab4.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab5.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab6.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
} else if (mPosition.equalsIgnoreCase("1")) {
mTab0.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab1.setColorFilter(mThemeContext.getResources().getColor(R.color.blink));
mTab2.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab3.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab4.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab5.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab6.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
} else if (mPosition.equalsIgnoreCase("2")) {
mTab0.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab1.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab2.setColorFilter(mThemeContext.getResources().getColor(R.color.red));
mTab3.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab4.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab5.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab6.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
} else if (mPosition.equalsIgnoreCase("3")) {
mTab0.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab1.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab2.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab3.setColorFilter(mThemeContext.getResources().getColor(R.color.blue));
mTab4.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab5.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab6.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
} else if (mPosition.equalsIgnoreCase("4")) {
mTab0.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab1.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab2.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab3.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab4.setColorFilter(mThemeContext.getResources().getColor(R.color.green));
mTab5.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab6.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
} else if (mPosition.equalsIgnoreCase("5")) {
mTab0.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab1.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab2.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab3.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab4.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab5.setColorFilter(mThemeContext.getResources().getColor(R.color.colorPrimaryDark));
mTab6.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
} else if (mPosition.equalsIgnoreCase("6")) {
mTab0.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab1.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab2.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab3.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab4.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab5.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab6.setColorFilter(mThemeContext.getResources().getColor(R.color.highlight_color_lxx_light));
} else {
mTab0.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab1.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab2.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab3.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab4.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab5.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
mTab6.setColorFilter(mThemeContext.getResources().getColor(R.color.key_background_lxx_dark));
}
}
}