当前位置: 首页 > news >正文

网站关键字怎么写网址大全查询网站

网站关键字怎么写,网址大全查询网站,wordpress wlw,装修公司起名简介 自定义PopupWindow, 适用于提示类弹窗。 使用自定义Drawable设置带箭头的背景#xff0c;测试控件和弹窗的尺寸#xff0c;自动设置弹窗的显示位置#xff0c;让箭头指向锚点控件的中间位置#xff0c;且根据锚点控件在屏幕的位置#xff0c;自动适配弹窗显示位置。…简介 自定义PopupWindow, 适用于提示类弹窗。 使用自定义Drawable设置带箭头的背景测试控件和弹窗的尺寸自动设置弹窗的显示位置让箭头指向锚点控件的中间位置且根据锚点控件在屏幕的位置自动适配弹窗显示位置。  适用于描述、解释弹窗。 一、效果 带箭头弹窗显示在控件的左侧箭头相对控件居中对齐 且与控件左边框挨着 示例代码如下 二、使用 GuZhiExplainPupopWindow window new GuZhiExplainPupopWindow(this);//设置弹窗显示文案window.setTips(1234567890-34567890-【qweqwertyuiop[sdfghjkl;zxcvbnm,.我们一起走向富强);//获取窗口的背景drawable对象ArrowsDrawable ad window.getArrowsDrawable();//设置drawable箭头的大小ad.setArrowsHeight(ConvertUtils.dp2px(8));//设置drawable中箭头与边框距离ad.setArrowsPadding(ConvertUtils.dp2px(10));//设置drawable的padding, 实际是设置显示文案的TextView的padding//ad.setPadding(ConvertUtils.dp2px(10));window.setPadding(ConvertUtils.dp2px(10));//设置drawable背景色ad.setColor(Color.DKGRAY);findViewById(R.id.tv33).setOnClickListener(view - {if (!window.isShowing()) {//设置窗口显示位置AUTO_HORIZONTAL 是水平位置在控件的左侧或右侧根据控件中心在屏幕中的位置决定window.setShowPosition(GuZhiExplainPupopWindow.AUTO_HORIZONTAL);//显示弹窗偏移量是0默认是箭头在控件居中位置window.show(view, 0, 0);}}); 三、自定义布局 重写initView方法并设置TipsTv 同时需要注意的是在设置弹窗布局时根布局的宽高属性是wrap_content设置其它是不生效的如果需要指定textView的宽或高或弹窗尺寸根布局使用某ViewGroup控件再设置其子控件的尺寸。 GuZhiExplainPupopWindow window new GuZhiExplainPupopWindow(this, R.layout.pupopwindow_view_guzhi_explain) {Overridepublic void initView(View contentView) {//自定义布局初始化控件super.initView(contentView);TextView customTv contentView.findViewById(R.id.explain_tv);setTipsTv(customTv);}}; 四、源码 package com.ttkx.deviceinfo.bkchart.popupwindow;import android.content.Context; import android.content.res.Resources; import android.graphics.Color; import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.PopupWindow; import android.widget.TextView;import com.blankj.utilcode.util.ConvertUtils; import com.blankj.utilcode.util.Utils; import com.ttkx.deviceinfo.R; import com.ttkx.deviceinfo.bkchart.ArrowsDrawable; import com.ttkx.deviceinfo.bkchart.GuZhiActivity;import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy;import androidx.annotation.IntDef; import androidx.core.widget.PopupWindowCompat;/*** 估值说明弹窗* Created by liuyu*/ public class SimpleTipsPupopWindow extends PopupWindow {private ArrowsDrawable mBgDrawable;private TextView mTipsTv;private int mShowPosition TOP;public static final int AUTO_VERTICAL Gravity.CENTER_VERTICAL;public static final int AUTO_HORIZONTAL Gravity.CENTER_HORIZONTAL;public static final int LEFT Gravity.LEFT;public static final int TOP Gravity.TOP;public static final int RIGHT Gravity.RIGHT;public static final int BOTTOM Gravity.BOTTOM;public SimpleTipsPupopWindow(GuZhiActivity context) {this(context, View.inflate(context, R.layout.pupopwindow_view_guzhi_explain, null));}public SimpleTipsPupopWindow(GuZhiActivity context, int layoutId) {this(context, View.inflate(context, layoutId, null));}public SimpleTipsPupopWindow(GuZhiActivity context, View contentView) {super(context);setContentView(contentView);setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));setOutsideTouchable(true);init(contentView);}private void init(View contentView) {mBgDrawable new ArrowsDrawable(ArrowsDrawable.TOP, ConvertUtils.dp2px(5));mBgDrawable.setCornerRadius(ConvertUtils.dp2px(4));mBgDrawable.setArrowsPadding(ConvertUtils.dp2px(10));mBgDrawable.setArrowsHeight(ConvertUtils.dp2px(5));boolean redMode true;mBgDrawable.setColor(Color.parseColor(redMode ? #e6292F3C : #f22b3346)); // mBgDrawable.setPadding(ConvertUtils.dp2px(10));mTipsTv contentView.findViewById(R.id.explain_tv);initView(contentView);}/*** 用于自定义布局 初始化* param contentView*/public void initView(View contentView) {}/*** 设置tips TextView* param tv*/public void setTipsTv(TextView tv) {mTipsTv tv;}private int makeDropDownMeasureSpec(int measureSpec) {int mode;if (measureSpec ViewGroup.LayoutParams.WRAP_CONTENT) {mode View.MeasureSpec.UNSPECIFIED;} else {mode View.MeasureSpec.EXACTLY;}return View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(measureSpec), mode);}public void setTips(String tips) {if (mTipsTv ! null) {mTipsTv.setText(tips);}}public void show(View anchor, int os, int oy) {if (mBgDrawable null) {return;}int showPosition mShowPosition;int offsetX 0;int offsetY 0;int locationX getLocationOnScreen(anchor)[0];int locationY getLocationOnScreen(anchor)[1];if (showPosition LEFT || showPosition RIGHT || showPosition AUTO_HORIZONTAL) {mBgDrawable.setArrowsPosition(ArrowsDrawable.LEFT, mTipsTv);getContentView().measure(makeDropDownMeasureSpec(getWidth()), makeDropDownMeasureSpec(getHeight()));int windowWidth this.getContentView().getMeasuredWidth();os anchor.getWidth();offsetY (int) -(anchor.getHeight() / 2 mBgDrawable.getArrowsCenterDistance());if (showPosition LEFT) {boolean showLeft locationX windowWidth;offsetX disHor(showLeft, windowWidth, anchor, os);} else if (showPosition RIGHT) {boolean showLeft !(getAppScreenWidth() - (locationX anchor.getWidth()) windowWidth);offsetX disHor(showLeft, windowWidth, anchor, os);} else if (showPosition AUTO_HORIZONTAL) {int screenWidth getAppScreenWidth();boolean showLeft locationX anchor.getWidth() / 2 screenWidth / 2;offsetX disHor(showLeft, windowWidth, anchor, os);}} else {mBgDrawable.setArrowsPosition(ArrowsDrawable.TOP, mTipsTv);//先设置箭头drawable方向为垂直方向的因箭头尺寸会影响到计算窗口的高度getContentView().measure(makeDropDownMeasureSpec(getWidth()), makeDropDownMeasureSpec(getHeight()));int windowHeight this.getContentView().getMeasuredHeight();os anchor.getWidth() / 2;offsetX (int) (os - mBgDrawable.getArrowsCenterDistance());if (showPosition TOP) {int distanceTop locationY - getStatusBarHeight();//锚点控件距离顶部距离//计算锚点控件在屏幕中的位置offsetY disVer(distanceTop windowHeight, windowHeight, anchor, oy);} else if (showPosition BOTTOM) {int distanceBottom getLocationOnScreen(anchor)[1] - anchor.getHeight() - getNavBarHeight();//锚点控件距离底部距离offsetY disVer(distanceBottom windowHeight, windowHeight, anchor, oy);} else if (showPosition AUTO_VERTICAL) {int appScreenHeight getAppScreenHeight();int anchorCenterY locationY anchor.getHeight() / 2;offsetY disVer(appScreenHeight / 2 anchorCenterY, windowHeight, anchor, oy);}}//设置textView的padding防止设置drawable背景不生效Rect padding mBgDrawable.getPadding();mTipsTv.setPadding(padding.left, padding.top, padding.right, padding.bottom);PopupWindowCompat.showAsDropDown(this, anchor, offsetX, offsetY, Gravity.START);}private int disHor(boolean showLeft, int windowWidth, View anchor, int ox) {int offsetX;if (showLeft) {//锚点控件在屏幕中上方反之在屏幕中下方mBgDrawable.setArrowsPosition(ArrowsDrawable.RIGHT);offsetX -windowWidth ox - anchor.getWidth();} else {mBgDrawable.setArrowsPosition(ArrowsDrawable.LEFT);offsetX ox;}return offsetX;}private int disVer(boolean showTop, int windowHeight, View anchor, int oy) {int offsetY 0;if (showTop) {//锚点控件在屏幕中上方反之在屏幕中下方mBgDrawable.setArrowsPosition(ArrowsDrawable.BOTTOM);offsetY -(windowHeight anchor.getHeight() oy);} else {mBgDrawable.setArrowsPosition(ArrowsDrawable.TOP);offsetY oy;}return offsetY;}public ArrowsDrawable getArrowsDrawable() {return mBgDrawable;}public void setPadding(int padding) {mBgDrawable.setPadding(padding);}IntDef({LEFT, RIGHT, TOP, BOTTOM, AUTO_VERTICAL, AUTO_HORIZONTAL})Retention(RetentionPolicy.SOURCE)public interface ShowPosition {}/*** 设置显示位置相对于锚点控件 左边、上方、右边、下面* 注意窗口相对控件的方向与箭头方向是相反的。* LEFT, RIGHT, TOP, BOTTOM** param showPosition*/public void setShowPosition(ShowPosition int showPosition) {mShowPosition showPosition;}private static int[] getLocationOnScreen(View view) {int[] location new int[2];view.getLocationOnScreen(location);return location;}private static int getStatusBarHeight() {// 获得状态栏高度Resources resources Resources.getSystem();int resourceId resources.getIdentifier(status_bar_height, dimen, android);return resources.getDimensionPixelSize(resourceId);}private static int getNavBarHeight() {Resources res Resources.getSystem();int resourceId res.getIdentifier(navigation_bar_height, dimen, android);if (resourceId ! 0) {return res.getDimensionPixelSize(resourceId);} else {return 0;}}private static int getAppScreenHeight() {WindowManager wm (WindowManager) Utils.getApp().getSystemService(Context.WINDOW_SERVICE);if (wm null) return -1;Point point new Point();wm.getDefaultDisplay().getSize(point);return point.y;}private static int getAppScreenWidth() {WindowManager wm (WindowManager) Utils.getApp().getSystemService(Context.WINDOW_SERVICE);if (wm null) return -1;Point point new Point();wm.getDefaultDisplay().getSize(point);return point.x;} }
http://www.pierceye.com/news/249043/

相关文章:

  • 潍坊优化网站排名在线网页设计培训机构
  • c做的网站ps做 网站标准尺寸
  • 老虎淘客系统可以做网站吗wordpress po mo
  • 网站的建设与维护那个网站做图片好
  • 昆山网站建设详细方案建设企业网站初始必备的六大功能
  • 做网站是前端还是后端网站规划 设计 制作 发布与管理过程
  • 黄山网站开发威县做网站哪里便宜
  • 网站怎么分类视频聚合网站怎么做不侵权
  • 有没有做问卷还能赚钱的网站套别人的网站模板吗
  • 东莞做汽车有没有买票的网站做谷歌推广一个月赚10万
  • 抚州城乡建设厅网站建设局官网查询
  • 汉中微信网站建设装修3d效果图怎么制作
  • wordpress 主题放哪站内关键词自然排名优化
  • 网站备案后经营做网站实例教程
  • 软件网站怎么做的python下载安装教程
  • 旅游网站开发分析报告网站建设教程搭建芽嘱湖南岚鸿信赖
  • 网站的配色方案高校网站建设意义
  • 滇中引水工程建设管理局网站网站开发怎样验收
  • ps制作网站logo阿里云网站备案拍照
  • 网站建设合同】wordpress翻书
  • 电商网站建设制作隆化县建设局网站
  • 宁波网站建设rswl网页美工设计教案
  • 贵州省住房城乡建设部网站json网站开发
  • 桥头网站仿做百度里面的站长工具怎么取消
  • 博物馆网站页面设计说明山东高端网站定制
  • python网站开发效率jsp做网站下载图片
  • 营销式网站建设免费注册个人网站官网
  • 高职高专 网站建设与维护开发一个网站平台多少钱
  • 网站后缀有哪些宜昌建设网站
  • iis做网站的流程wordpress有中文版没