dialog显示不全,布局显示不全,下边框显示不全,只显示一半的BUG

【dialog显示不全,布局显示不全,下边框显示不全,只显示一半的BUG】有问题的代码
RelativeLayout layout;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);layout = findViewById( R.id.content);layout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT ,RelativeLayout.LayoutParams.WRAP_CONTENT));}
有问题的是:关键部分是 , 高度设置为自适应导致的 , 由于代码设置自适应导致布局 , 有时候中间代码动态设置宽高 , 跟xml布局宽高冲突之后导致部分高度设置有误

dialog显示不全,布局显示不全,下边框显示不全,只显示一半的BUG

文章插图
解决方法:把宽度、高度自适应都换成.
RelativeLayout layout;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);layout = findViewById( R.id.content);layout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT ,RelativeLayout.LayoutParams.MATCH_PARENT));}