[英]How to fix or set the label height and width with respect to GridPane row height and column width by using JavaFX and Scene Builder?
[英]How to set width of view with respect to value in android
如何根據值更改第二個視圖長度。 如果第一個值為 100,則寬度為 match_parent。 如果第二個值為 60,那么如何根據該值設置其寬度。
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:layout_below="@+id/headerproject">
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@color/grey">
</View>
<View
android:layout_width="200dp"
android:layout_height="5dp"
android:background="@color/colorPrimary"
>
</View>
</RelativeLayout>
您可以使用ProgressBar
但如果您真的需要 go 以這種方式,您可以設置綠色條的寬度,如:
View viewGray, viewGreen;
int currentValue, totalValue;
//Some relevant code
viewGray.postDelayed(new Runnable() {
@Override
public void run() {
int parentWith = viewGray.getWidth();
int viewGrayWith = parentWith * (currentValue/(float)totalValue);
viewGreen.getLayoutParams().width = viewGrayWith;
}
},50);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.