【发布时间】:2020-11-24 16:44:11
【问题描述】:
我在相对布局中有五个按钮,如果我尝试动态更改它们的高度,一些按钮会消失。
How buttons are looking before clicking
val w = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 45f, resources.displayMetrics)
btn_ran.setOnClickListener {
btn_1.layoutParams = RelativeLayout.LayoutParams(w.toInt(), 700)
btn_3.layoutParams = RelativeLayout.LayoutParams(w.toInt(), 700)
btn_4.layoutParams = RelativeLayout.LayoutParams(w.toInt(), 700)
btn_2.layoutParams = RelativeLayout.LayoutParams(w.toInt(), 700)
btn_5.layoutParams = RelativeLayout.LayoutParams(w.toInt(), 700)
}
我想要做的就是在单击按钮时随机更改所有按钮的高度。
【问题讨论】:
-
他们可能会离开屏幕视图。试着把它放在一个滚动视图中。
标签: android android-studio android-layout android-view android-button