
2、设置imageview的图片
3、添加到布局中
示例代码
ViewGroup group = (ViewGroup) findViewById(R.id.viewGroup)//获取原来的布局容器
ImageView imageView = new ImageView(this) //创建imageview
imageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)) //image的布局方式
imageView.setImageResource(R.drawable.ic_launcher) //设置imageview呈现的图片
group.addView(imageView) //添加到布局容器中,显示图片。
LayoutInflater mLayoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE)View menuView = (View)mLayoutInflater.inflate(R.layout.alert_dialog_menu_layout_new, null, true)//d出窗口包含的视图
popupWindow = new PopupWindow(menuView, LayoutParams.FILL_PARENT,238, true)//创建d出窗口,指定大小 popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.btn_style_alert_dialog_background))//设置d出窗口的背景
popupWindow.setAnimationStyle(R.style.PopupAnimation)//设置窗口显示的动画效果
popupWindow.showAtLocation(findViewById(R.id.parent), Gravity.BOTTOM, 0, 0)//设置窗口显示的位置
popupWindow.update()
Style.xml文件:
<style name="PopupAnimation" parent="android:Animation">
<item name="android:windowEnterAnimation">@anim/menu_up</item>
</style>
Meun_up.xml文件:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:duration="500" android:fromXDelta="0.0" android:toXDelta="0.0" android:fromYDelta="100%" android:toYDelta="50%" />
</set>
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)