- Jun 16, 2023
- 1
- 0
- 1
i am using androidx.constraintlayout.widget.ConstraintLayout,but I don't know how to set a percent height.
the layout.xml is as follow:
<androidx.camera.view.PreviewView
android:id="@+id/viewFinder"
class="androidx.camera.view.PreviewView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_constraintHeight_percent="0.9"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
but it can't be built:
-mergeDebugResources-35:/layout/activity_main.xml:18: error: attribute android:layout_constraintHeight_percent not found.
It should include android.support.percent, but in the
developer.android.com
Note: As of release 26.0.0, the Percent Support library is deprecated. Clients of this module should migrate to the new ConstraintLayout widget, which is provided as a separate artifact in SDK Manager.
How do I use the new method to replace it?
the layout.xml is as follow:
<androidx.camera.view.PreviewView
android:id="@+id/viewFinder"
class="androidx.camera.view.PreviewView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_constraintHeight_percent="0.9"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
but it can't be built:
-mergeDebugResources-35:/layout/activity_main.xml:18: error: attribute android:layout_constraintHeight_percent not found.
It should include android.support.percent, but in the

android.support.percent | Android Developers

Note: As of release 26.0.0, the Percent Support library is deprecated. Clients of this module should migrate to the new ConstraintLayout widget, which is provided as a separate artifact in SDK Manager.
How do I use the new method to replace it?