Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

可以弹出DIalog时,增加让dialog居中显示嘛,效果类似今日头条首页删除某条新闻时弹出的那个框 #4

Closed
wolf8088521 opened this issue Mar 31, 2018 · 12 comments

Comments

@wolf8088521
Copy link

default

@xujiaji
Copy link
Owner

xujiaji commented Mar 31, 2018

@wolf8088521 你是说dialog以屏幕左右居中显示吗?那么箭头怎么指?比如说内容比屏幕短很多,但是触发的按钮又在最边缘

@wolf8088521
Copy link
Author

也不能就是说居中显示把,可以让用户自己去控制这个宽度嘛。你说的这种场景,不可以让用户设置自己去设置宽度嘛,我现在设置的match_parent,也不会填充满,是有最大宽度的限制吗? 我想到一种,就是在用户可以设置自由宽度的基础上,我说一种场景:就像头条那样,点击最右边那个删除按钮,是不是可以得到距离右边屏幕边缘的距离,在使用者可以自由设置宽度的时候,是不是可以提供一个函数,让不让左右两边设置等距离(这算不算一种假象的居中显示呢)。 不知道我表达清楚不清楚!

@xujiaji
Copy link
Owner

xujiaji commented Mar 31, 2018

我能不能这么理解:能设置match_parent撑开,能设置外边距?

@wolf8088521
Copy link
Author

是这意思,设置match_parent 横向填充满,设置外边距 其实就是一种假象剧中了 这样场景我感觉就比较符合今日头条这种形式了

@xujiaji
Copy link
Owner

xujiaji commented Apr 2, 2018

嗯,这个可以增加( • ̀ω•́ )✧

@wolf8088521
Copy link
Author

谢谢 博主

@wolf8088521
Copy link
Author

等待好消息

@xujiaji
Copy link
Owner

xujiaji commented Apr 2, 2018

可以了,你可以安装apk或用打包好的aar看一看。

通过下面的方法设置

    /**
     * @param width 设置气泡的宽
     * @param height 设置气泡的高
     * @param margin 设置距离屏幕边缘的间距,只有当设置 width 或 height 为 MATCH_PARENT 才有效
     */
setLayout(int width, int height, int margin)

例子

                mCurrentDialog = new BubbleDialog(this)
                        .addContentView(LayoutInflater.from(this).inflate(R.layout.dialog_view, null))
                        .setClickedView(mButton11)
                        .setPosition(mPosition)
                        .calBar(true)
                        .softShowUp()
                        .autoPosition(isAuto)
                        .setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
                                Util.dpToPx(this, 200),
                                Util.dpToPx(this, 32))
                        .setThroughEvent(mCheckBoxThrough.isChecked(), true);
                mCurrentDialog.show();

效果

device-2018-04-02-132813

demo apk和 类库 aar.zip

@wolf8088521
Copy link
Author

非常感谢博主。没提交git嘛 ,我fork下来没有哎。 请问这个autoPosition()自动定位弹出,是自动根据控件定位四个方向嘛(上下左右)。还是说可以调某个函数,指定自动定位(上下方向)或左右方向

@xujiaji
Copy link
Owner

xujiaji commented Apr 2, 2018

那我提交一下,没什么问题过两天我就更新一下版本。
通过autoPosition设置为true,那么自动根据相对于被点击view距离四周的空间多少确定显示位置(显示在最大空间)。也可以通过setPosition自己确定位置(autoPosition为ture时无效)

@wolf8088521
Copy link
Author

嗯 现在有指定一个方向弹出,和目前这种autoPosition()。 要不要增加一个自定义自动定位弹出(指定:只在控件的上下方向弹出)或只在左右方向弹出呢。有群嘛可以加下

@xujiaji
Copy link
Owner

xujiaji commented Apr 2, 2018

确实也对应着一些需要,可以加入这个功能。没有群,方便的话可以加一个QQ:624719201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants