我在所有活动中创建了TapTargetView(或TapTargetSequence)并且显示效果很好,但是对于弹出菜单的内部视图,它隐藏在我的弹出菜单窗口后面!正好在活动和弹出菜单之间。我怎么能把它带到顶部,拜托? TapTargetSequence((Activity)context的参数)是否正确? “context”或“this”发生错误!
public class Popup_Menu implements OnClickListener {
PopupWindow popup; View layout; Context context;
WindowManager wm;
void showPopup(final Activity context) {
this.context=context;
// Inflate the popup_layout.xml
LinearLayout viewGroup = (LinearLayout) ((Activity) context).findViewById(R.id.popup);
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layout = layoutInflater.inflate(R.layout.popup_layout_menu, viewGroup);
// Creating the PopupWindow
popup = new PopupWindow(context);
popup.setContentView(layout);
// Clear the default translucent background
popup.setBackgroundDrawable(new BitmapDrawable());
popup.showAtLocation(layout, Gravity.BOTTOM, 30 ,0 );
tapTarget_menu();
} /////////////////// close of showPopup() !
// TapTaget_menu
public void tapTarget_menu() {
new TapTargetSequence((Activity) context)
.targets(
TapTarget.forView(layout.findViewById(R.id.chkb_menu_remem), "remember", "last lesson")
// first target
.targetCircleColor(R.color.sabz_seyedi)
.outerCircleColor(R.color.sabzabi_kmrng)
.dimColor(R.color.sabz_seyedi)
.titleTextSize(22)
.descriptionTextSize(16)
.textColor(R.color.white)
.drawShadow(true)
.transparentTarget(true)
.cancelable(false)
.targetRadius(60),
// second target
TapTarget.forView(layout.findViewById(R.id.ll_call_menu), "call", "connecting friends!")
.targetCircleColor(R.color.sabz_seyedi)
.outerCircleColor(R.color.sabzabi_tireh)
.dimColor(R.color.sabz_seyedi)
.titleTextSize(22)
.descriptionTextSize(16)
.textColor(R.color.white)
.drawShadow(true)
.transparentTarget(true)
.cancelable(false)
.targetRadius(60)
).start();
}
}
答案 0 :(得分:-1)
我找到了解决办法!我在popup.showAtLocation()之后更改了此代码,如下所示,它可以在PopupWindow上显示tapTargetView。 VIVA ME !!!
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
layoutParams.packageName = context.getPackageName();
layoutParams.format = PixelFormat.TRANSLUCENT;
layoutParams.flags = WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
然后,showPopup()方法:
public void tapTarget_menu1(){
TapTarget target = TapTarget.forView(layout.findViewById(R.id.ll_call_menu), "remember", "last lesson");
.targetCircleColor(R.color.sabz_seyedi)
.outerCircleColor(R.color.sabzabi_tireh)
.titleTextSize(24)
.descriptionTextSize(18)
.textColor(R.color.black)
.drawShadow(true)
.cancelable(false)
.transparentTarget(true)
.targetRadius(60);
content = (ViewGroup) layout.findViewById(android.R.id.content);
final TapTargetView tapTarget_menu1 = new TapTargetView(context, wm, content, target, new TapTargetView.Listener(){
@Override
public void onTargetClick(TapTargetView view) {
tapTarget_menu2();
super.onTargetClick(view);
}
});
((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).addView(tapTarget_menu1, layoutParams);
}