Customized Spinner Dialog with unwanted space

前端 未结 2 1125
梦如初夏
梦如初夏 2021-01-23 15:36

I\'m creating a custom Dialog that is started by a custom spinner. What I was trying to do is customize the dialog the spinner calls. However, there is an annoying space in the

2条回答
  •  温柔的废话
    2021-01-23 16:11

    I solved it following the documentation

    And based in this code as advised by the documentation link above:

    AlertDialog.Builder builder;
    AlertDialog alertDialog;
    
    Context mContext = getApplicationContext();
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.custom_dialog,
                                   (ViewGroup) findViewById(R.id.layout_root));
    
    TextView text = (TextView) layout.findViewById(R.id.text);
    text.setText("Hello, this is a custom dialog!");
    ImageView image = (ImageView) layout.findViewById(R.id.image);
    image.setImageResource(R.drawable.android);
    
    builder = new AlertDialog.Builder(mContext);
    builder.setView(layout);
    alertDialog = builder.create();
    

提交回复
热议问题