I am working on an app, and I need to create a kind of gauge looking tile. So basically, I have created a simple xml file. with the layout I need, and all the views, like below:
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/tile_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_columnWeight="1"
android:background="@color/transparent">
<View
android:id="@+id/gauge"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible"/>
...
the, in the fragment, I am doing:
val layout: ConstraintLayout = view.findViewById(R.id.tile_layout)
val gauge = view.findViewById<View>(R.id.gauge)
val ratio = 75
view.layoutParams = getParams()
val newParams: ViewGroup.LayoutParams = gauge.layoutParams
newParams.height = (layout.height * ratio / 100)
gauge.setLayoutParams(newParams)
it's not working the height is still the same. I am looking to have the gauge view height about 75% of the layout height.
Any idea how ?