有个遮盖层的效果,但不全是遮盖层。(直接覆盖一层的代码我也有,但是有挖空的效果。想了很多方法不知道怎么实现。)
有知道怎么实现。奖励支付宝金额50-100元
之前直接用新的一层盖上去。
实现的代码如下:
private void getGuidePage(WcsApplication mWcsApplication) {
Rect frame = new Rect();
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
int statusBarHeight = frame.top;
final ViewGroup viewgroup = (ViewGroup) activity.getWindow().getDecorView();
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
final FrameLayout framelayout = new FrameLayout(activity);
framelayout.setPadding(0, statusBarHeight, 0, 0);
framelayout.setLayoutParams(params);
framelayout.setBackgroundColor(getResources().getColor(R.color.gray_transparent));
final ImageView guideIv = new ImageView(activity);
FrameLayout.LayoutParams guideIvLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT);
int marginHeight = getActivity().findViewById(R.id.edtTxt_search).getHeight();
guideIvLayoutParams.setMargins(0, marginHeight, 20, 0);
// TODO;;
guideIv.setLayoutParams(guideIvLayoutParams);
guideIv.setScaleType(ScaleType.FIT_CENTER);
guideIv.setImageResource(R.drawable.bg_search_city);
// guideIv.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// AlphaAnimation alpha = new AlphaAnimation(1, 0);
// alpha.setDuration(500);
// guideIv.startAnimation(alpha);
// guideIv.postDelayed(new Runnable() {
// @Override
// public void run() {
// viewgroup.removeView(framelayout);
// }
// }, 500);
// }
// });
framelayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlphaAnimation alpha = new AlphaAnimation(1, 0);
alpha.setDuration(500);
guideIv.startAnimation(alpha);
guideIv.postDelayed(new Runnable() {
@Override
public void run() {
viewgroup.removeView(framelayout);
}
}, 500);
}
});
framelayout.addView(guideIv);
viewgroup.addView(framelayout);
GuideHelper.setFragmentGuided(mWcsApplication, this);
}
能实现成如下效果:
等于全部覆盖。这样子的效果。有个坏处就是,位置根据不同分辨率的手机可能有偏差。位移啥的。为了防止偏差,采用挖空的效果来实现。
看了部分的类似这样的效果。点击这里 但是这个代码需要改来改去实现,非常麻烦。。这个可以改。需要改很多东西,改了两天发现没有进展。
只能实现类似效果。: