【发布时间】:2018-03-12 21:08:48
【问题描述】:
【问题讨论】:
-
请更具体。什么是问题?将不同背景的边界上的视图对齐是什么意思?请发布一些代码
-
@muminers 解决方案已在下方发布。
标签: android android-constraintlayout
【问题讨论】:
标签: android android-constraintlayout
您可以使用水平参考线来完成此操作。
可以在顶视图结束之前设置一个 X dp,在第二个视图开始之后设置另一个 X dp。
最后,进度可以垂直限制在两条准则的中间。
【讨论】:
我的回答是基于这个答案的想法(answer of Juan)
代码如下:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/col_yellow"
app:layout_constraintBottom_toTopOf="@+id/g_top"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<android.support.constraint.Guideline
android:id="@+id/g_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent=".4"/>
<android.support.constraint.Guideline
android:id="@+id/g_top_above"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent=".35"/>
<android.support.constraint.Guideline
android:id="@+id/g_top_below"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent=".45"/>
<ProgressBar
android:id="@+id/pb_completion"
style="@android:style/Widget.Material.ProgressBar.Horizontal"
android:layout_width="0dp"
android:layout_height="15dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:progressDrawable="@drawable/progress_background_layer_list"
app:layout_constraintBottom_toTopOf="@+id/g_top_below"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/g_top_above"
tools:progress="100"/>
</android.support.constraint.ConstraintLayout>
【讨论】: