Giter Club home page Giter Club logo

Comments (13)

junixapp avatar junixapp commented on August 16, 2024

@ygeng
使用的是最新版本吗?

from xpopup.

ygeng avatar ygeng commented on August 16, 2024

@ygeng
使用的是最新版本吗?

是的

from xpopup.

junixapp avatar junixapp commented on August 16, 2024

@ygeng
贴下代码,我这里无法复现。

from xpopup.

ygeng avatar ygeng commented on August 16, 2024
class BottomDialog (var activity: Activity) : BottomPopupView(activity) {

    private val TAG = BottomDialog::class.java.simpleName
    private lateinit var tvText1: TextView
    private lateinit var tvText2: TextView
    private lateinit var tvCancel: TextView
    private var text1: String = ""
    private var text2: String = ""
    private var cancel: String = "取消"
    private var onItemClickListener: OnItemClickListener ?= null

    override fun getImplLayoutId(): Int {
        return R.layout.layout_bottom_dialog
    }

    override fun initPopupContent() {
        super.initPopupContent()
        tvText1 = findViewById<TextView>(R.id.tv_text1)
        tvText2 = findViewById<TextView>(R.id.tv_text2)
        if (!text1.isEmpty()) {
            tvText1.text = text1
        }
        tvText1.setOnClickListener {
            if (onItemClickListener != null) {
                onItemClickListener?.onItemClick(0)
            } else {
                Log.e(TAG, "Please set OnUserSelectListener!!!")
            }
        }
        if (!text2.isEmpty()) {
            tvText2.text = text2
        }
        tvText2.setOnClickListener {
            if (onItemClickListener != null) {
                onItemClickListener?.onItemClick(1)
            } else {
                Log.e(TAG, "Please set onItemClickListener!!!")
            }
        }
        tvCancel = findViewById<TextView>(R.id.tv_cancel)
        tvCancel.text = cancel
        tvCancel.setOnClickListener {
            if (onItemClickListener != null) {
                onItemClickListener?.onItemClick(2)
            } else {
                Log.e(TAG, "Please set onItemClickListener!!!")
            }
        }
    }

    fun setText(text1: String, text2: String, cancel: String): BottomDialog {
        this.text1 = text1
        this.text2 = text2
        this.cancel = cancel
        return this
    }

    fun setOnItemClickListener(onItemClickListener: OnItemClickListener): BottomDialog {
        this.onItemClickListener = onItemClickListener
        return this
    }

    interface OnItemClickListener {
        fun onItemClick(position: Int)
    }
}

from xpopup.

ygeng avatar ygeng commented on August 16, 2024

可以在外部使用手势向下滑动关闭对话框,但是点击外部没有反应

from xpopup.

junixapp avatar junixapp commented on August 16, 2024

@ygeng
显示弹窗那部分代码贴下。

from xpopup.

ygeng avatar ygeng commented on August 16, 2024
if (selectImageDialog == null) {
            selectImageDialog = BottomDialog(this).setText(getString(R.string.take_picture), getString(R.string.select_from_album), getString(R.string.cancel))
                    .setOnItemClickListener(object : BottomDialog.OnItemClickListener {
                        override fun onItemClick(position: Int) {
                            when (position) {
                                0 -> {
                                    openCamera()
                                    XPopup.get(mContext).dismiss()
                                }
                                1 -> {
                                    openAlbum()
                                    XPopup.get(mContext).dismiss()
                                }
                                2 -> {
                                    XPopup.get(mContext).dismiss()
                                }
                            }
                        }
                    })
        }

        XPopup.get(this).asCustom(selectImageDialog).dismissOnTouchOutside(true).autoDismiss(true).show()

from xpopup.

junixapp avatar junixapp commented on August 16, 2024

@ygeng
代码看起来并没有特殊的地方,可以加我QQ:16167479。把出问题的demo发我一份,我帮你看看。

from xpopup.

ygeng avatar ygeng commented on August 16, 2024

大佬,知道问题了,我的布局设置的match_parent导致的,改成wrap_content就可以了

from xpopup.

junixapp avatar junixapp commented on August 16, 2024

@ygeng
怪我没特意说明,现在加了说明:
image

from xpopup.

ygeng avatar ygeng commented on August 16, 2024

好的,感谢大佬🙏

from xpopup.

zaaach avatar zaaach commented on August 16, 2024

自定义bottom弹窗,启用手势,布局高度是match_parent的,指定maxheight,但是hasShadowBg(true)方法失效(弹窗以外没有半透明背景)
三星Galaxy A9
Android 8.0

from xpopup.

zaaach avatar zaaach commented on August 16, 2024

如果布局改为wrap_content,hasShadowBg(true)有效果,但是第一次弹出来的高度很小,并且向下滑动到看不见后,界面无法点击(弹窗应该没有dismiss)在屏幕上向上滑动还可以滑出来

from xpopup.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.