需要在创建过程中设置Layout宽高为 LayoutParams.WRAP_CONTENT
public class CustomizedDialog extends Dialog
{
........
@Override
protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);
setContentView(R.layout.mydialog);
getWindow().setLayout(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);//需要添加的语句
}
..........
}