如何将ImageView的布局设置为仅使用XML的父布局的1/4。我还想避免使用嵌套在父ConstraintLayout中的LinearLayout来做这件事。
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/fragprofile_profile_picture"
android:layout_width="0dp"
android:layout_height="75dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>发布于 2020-03-03 10:30:46
您可以使用Guideline。
垂直导轨。
<androidx.constraintlayout.widget.Guideline
android:id="@+id/start_guide_line"
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.25"
/>水平导轨
<androidx.constraintlayout.widget.Guideline
android:id="@+id/top_guide_line"
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.25"
/>https://stackoverflow.com/questions/60499129
复制相似问题