Необходимо показать вид выше панели поиска в определенной позиции Android - PullRequest
0 голосов
/ 05 февраля 2019

Я хочу показать seekbar с пунктирной линией согласно изображениям ниже.Эта строка будет отображаться динамически на основе низкого / высокого значения.Я приложил ниже изображение. enter image description here

Я достиг ниже изображения.Не могли бы вы помочь мне в этом?

enter image description here

1 Ответ

0 голосов
/ 05 февраля 2019

Добавьте индикатор выполнения в макет ограничения и установите его ширину, соответствующую родительскому элементу.Добавьте два изображения сверху, которые имеют пунктирную линию в качестве ресурса.Добавьте две вертикальные направляющие и ограничьте каждый вид изображения соответствующей направляющейУстановите процент ориентиров, чтобы вы всегда находились там, где хотите, на индикаторе выполнения, и представления будут перемещаться соответствующим образом.Вы можете программно изменить процент рекомендаций следующим образом:

Guideline guideLineLeft = (Guideline) findViewById(R.id.your_left_guideline);
Guideline guideLineRight = (Guideline) findViewById(R.id.your_right_guideline);
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) guideLineLeft.getLayoutParams();
params.guidePercent = 0.10f; // 10% 
guideLineLeft.setLayoutParams(params);
guideLineRight.getLayoutParams();
params.guidePercent = 0.90f; // 90% 
guideLineRight.setLayoutParams(params);

ОБНОВЛЕНИЕ после комментария :

example

<?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"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toStartOf="@+id/guideline"
        app:srcCompat="@drawable/ic_divider_more" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toStartOf="@+id/guideline2"
        app:srcCompat="@drawable/ic_divider_more" />

    <android.support.constraint.Guideline
        android:id="@+id/guideline"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_percent="0.21" />

    <android.support.constraint.Guideline
        android:id="@+id/guideline2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_percent="0.80"/>

</android.support.constraint.ConstraintLayout>
...