<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="1000"
android:fromYDelta="0"
android:toYDelta="50%p" />
<alpha
android:duration="1000"
android:fromAlpha="1.0"
android:toAlpha="0.0" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="1000"
android:fromYDelta="100%p"
android:toYDelta="0" />
<alpha
android:duration="1000"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
<style name="mypopwindow_anim_style">
<item name="android:windowEnterAnimation">@anim/popshow_anim</item>
<!-- 指定显示的动画xml -->
<item name="android:windowExitAnimation">@anim/pophidden_anim</item>
<!-- 指定消失的动画xml -->
</style>
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.popupwindows, null);
se_recicler = view.findViewById(R.id.se_recicler);
ye.add("黑色");
ye.add("白色");
ye.add("黄色");
ye.add("紫色");
ye.add("蓝色");
ye.add("红色");
yeint.add(Color.BLACK); //黑色
yeint.add(Color.WHITE); //蓝色
yeint.add(Color.YELLOW); //黄色
yeint.add(Color.RED); //红色
yeint.add(Color.CYAN); //蓝色
yeint.add(Color.MAGENTA);
myAdapterys = new MyAdapterys(ye,yeint);
se_recicler.setAdapter(myAdapterys);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(HomeAtivity.this);
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
se_recicler.setLayoutManager(linearLayoutManager);
// 下面是两种方法得到宽度和高度 getWindow().getDecorView().getWidth()
PopupWindow window = new PopupWindow(view,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT);
// 设置popWindow弹出窗体可点击,这句话必须添加,并且是true
window.setFocusable(true);
// 实例化一个ColorDrawable颜色为半透明
ColorDrawable dw = new ColorDrawable(0xb0000000);
window.setBackgroundDrawable(dw);
// 设置popWindow的显示和消失动画
window.setAnimationStyle(R.style.mypopwindow_anim_style);
// 在底部显示
window.showAtLocation(HomeAtivity.this.findViewById(R.id.start),
Gravity.BOTTOM, 0, 0);
myAdapterys.setOnChangeyeListener(new MyAdapterys.OnChangeyeListener() {
@Override
public void onClickheise(View view, int position) {
String s = ye.get(position);
if (s.equals("白色")){
onTheme(android.R.style.Theme_Light);
}else if (s.equals("黑色")){
onTheme(android.R.style.Theme_Black);
}else if (s.equals("黄色")){
linearlayoutYj.setBackgroundColor(Color.YELLOW);
Toast.makeText(HomeAtivity.this,
"点击返回上一层本次主题只更换侧边栏",
Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(HomeAtivity.this,
"简单实现暂不开发",
Toast.LENGTH_SHORT).show();
}
}
});
window.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
System.out.println("popWindow消失");
}
});
推荐有意思的动画 https://www.cnblogs.com/zzw1994/p/5035913.html