Reputation: 435
I should achieve such effect in ConstraintLayout
as below
I know how to create the custom ProgressBar
, but I have no idea
how to align this view
on the border of different backgrounds
Please, provide a hint.
Upvotes: 0
Views: 495
Reputation: 435
My answer is based on idea of this answer( answer of Juan )
Code below:
<?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>
Upvotes: 1
Reputation: 5589
You may be able to acomplish this using horizontal guidelines.
One can be set X dp before the end of the top view and another one X dp after the begining of the second view.
And finally the progress could be vertically constrined in the middle betwee the two guidelines.
Upvotes: 1