如何在Android应用中添加一个自定义弹框

  介绍

如何在Android应用中添加一个自定义弹框?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

<强>实现步骤:

& lt;及# 63;xml version=?.0”;编码=皍tf-8", # 63;比;   http://schemas.android.com/apk/res/android" & lt; RelativeLayout xmlns: android=?;   android: layout_width=癿atch_parent"   android: layout_height=癿atch_parent"   android:背景=癅drawable/store_bgimg"比;   & lt;使用   android: layout_width=癴ill_parent"   android: layout_height=?14 dp"   android: layout_centerVertical=皌rue"   android: layout_marginLeft=?1 dp"   android: layout_marginRight=?1 dp"   android:背景=癅drawable/tkbjzj"比;   & lt; TextView   android: id=癅 + id/tetle"   android: layout_width=皐rap_content"   android: layout_height=皐rap_content"   android: layout_centerHorizontal=皌rue"   android: layout_marginTop=?6 dp"   android:文本=捌咛炝频辍?   输入textColor=癮ndroid: # 262626“;   android: textSize=?8 dp"/比;   & lt; TextView   android: id=癅 + id/textdz"   android: layout_width=皐rap_content"   android: layout_height=皐rap_content"   android: layout_below=癅 + id/tetle"   android: layout_centerHorizontal=皌rue"   android: layout_marginTop=?4 dp"   android:文本=澳阋蚜烊”镜?.5折优惠券”;   输入textColor=癮ndroid: # ea302e"/比;   & lt;视图   android: layout_width=癿atch_parent"   android: layout_height=?.5 dp"   android: layout_above=癅 + id/lineardb"   android:背景=? e6e6e6"/比;   LinearLayout & lt;   android: id=癅 + id/lineardb"   android: layout_width=癿atch_parent"   android: layout_height=?4 dp"   android: layout_alignParentBottom=皌rue"比;   & lt; TextView   android: id=癅 + id/textwzdl"   android: layout_width=? dp"   android: layout_height=癴ill_parent"   android: layout_weight=?”;   android:重力=癱enter"   android:文本=拔抑懒恕?   输入textColor=癮ndroid: # 262626“;   android: textSize=?6 dp"/比;   & lt; TextView   android: id=癅 + id/textckxq"   android: layout_width=? dp"   android: layout_height=癴ill_parent"   android: layout_weight=?”;   android:背景=? f86c6a"   android:重力=癱enter"   android:文本=安榭聪昵椤?   输入textColor=癮ndroid: # ffffff"   android: textSize=?6 dp"/比;   & lt;/LinearLayout>   & lt;/RelativeLayout>   & lt;/RelativeLayout>

& lt;及# 63;xml version=?.0”;编码=皍tf-8", # 63;比;   & lt;形状xmlns: android=癶ttp://schemas.android.com/apk/res/android"比;   & lt; !——背景颜色——比;   & lt;固体android:颜色=? ffffff"/比;   & lt; !——控制边界线颜色和大小——比;   & lt;中风   android:宽度=? dp"   android:颜色=? ffffff"/比;   & lt; !——控制圆角大小——比;   & lt;角落android:半径=? dp"/比;   & lt;/shape>

/* *   *弹框   */私人观点mPopupHeadViewy;//创建一个视图   私人PopupWindow mHeadPopupclly;//PopupWindow   私人TextView tetle textdz;//标题,打折   私人TextView textwzdl textckxq;//我知道了,查看详情   @SuppressWarnings (“deprecation")   私人空间popupHeadWindowcll () {   mPopupHeadViewy=View.inflate (getActivity(),出来。tankuang_layout, null);   tetle=(TextView) mPopupHeadViewy.findViewById (R.id.tetle);   textdz=(TextView) mPopupHeadViewy.findViewById (R.id.textdz);   textwzdl=(TextView) mPopupHeadViewy.findViewById (R.id.textwzdl);   textckxq=(TextView) mPopupHeadViewy.findViewById (R.id.textckxq);   mHeadPopupclly=new PopupWindow (mPopupHeadViewy AbsListView.LayoutParams。MATCH_PARENT AbsListView.LayoutParams。MATCH_PARENT,真正的);//在PopupWindow里面就加上下面代码,让键盘弹出时,不会挡住流行窗口。   mHeadPopupclly.setInputMethodMode (PopupWindow.INPUT_METHOD_NEEDED);   mHeadPopupclly.setSoftInputMode (WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);   mHeadPopupclly。setBackgroundDrawable(新BitmapDrawable ());   mHeadPopupclly.setOutsideTouchable(真正的);   mHeadPopupclly。showAsDropDown (textviewid, 0, 0);   textwzdl。setOnClickListener(新View.OnClickListener () {   @Override   公共空间> mHeadPopupclly=new PopupWindow (mPopupHeadViewy AbsListView.LayoutParams。MATCH_PARENT AbsListView.LayoutParams。MATCH_PARENT,真);

2,

如何在Android应用中添加一个自定义弹框