[英]How get member value from xml element
<EditText
android:id="@+id/x"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<EditText
android:id="@+id/y"
android:layout_width="match_parent"
android:layout_height="x.layout_height*2">
Code above doesn't work of course.上面的代码当然不起作用。 How can I get height from x
and eg multiply this value by 2. Is it possible?如何从x
获取高度,例如将此值乘以 2。这可能吗? Or I should define always some constraint for this?或者我应该始终为此定义一些约束?
Try this尝试这个
//Java
@Override
protected void onCreate(Bundle savedInstanceState) {
EditText x = findViewById(R.id.x);
EditText y = findViewById(R.id.y);
y.setHeight(x.getHeight() * 2);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.