Android - change dialog button location

前端 未结 4 667
无人及你
无人及你 2021-01-13 14:09

Is it possible to change the location of the button on the dialog to the outside of the dialog itself? something like this (the red squares are buttons):

4条回答
  •  醉梦人生
    2021-01-13 14:59

    
    
    
    
    
        
    
    
    

    Instead of using default alert dialog, make a custom layout something like my layout here. And perform desired action on button.

    You can call n show this layout without inflating like this. EDIT:1

     public void showUpdateLayout() {
        mParentView = (ViewGroup) findViewById(android.R.id.content);
        if (mParentView != null) {
            LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
            mUpdateLayout = inflater.inflate(R.layout.upadte_layout, mParentView, false);
            mParentView.addView(mUpdateLayout);
            if (mUpdateLayout != null) {
                mUpdateLayout.setVisibility(View.VISIBLE);
            }
        }
    

    Write this method in ur public Class (or Custom Aprent Activity). and call this method when u need to alert.

提交回复
热议问题