TextView смещается к середине экрана - PullRequest
0 голосов
/ 09 ноября 2018

У меня проблема с тем, что мои TextView's или что я использую AutoResizeTextView смещаются в середину экрана, когда ImageView's (с идентификатором @+id/download_complete_indicator и @+id/download_complete_indicator), которые скрыты в начало visible.

Вот мой ItemView.

<?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"
    xmlns:tools="http://schemas.android.com/tools">

    <android.support.v7.widget.CardView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="parent">

        <android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <com.myAppName.Songplayer.Utils.AutoResizeTextView
                android:id="@+id/video_title"
                android:layout_width="220dp"
                android:layout_height="27dp"
                android:layout_marginStart="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginBottom="8dp"
                android:text="Title"
                android:textAppearance="@style/TextAppearance.AppCompat.Headline"
                android:textColor="@color/colorPrimaryTextDefaultMaterialLight"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toStartOf="@+id/song_cost_layout_songlist"
                app:layout_constraintHorizontal_bias="1.0"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_bias="0.052" />


            <com.myAppName.Songplayer.Utils.AutoResizeTextView
                android:id="@+id/uploader_username"
                android:layout_width="220dp"
                android:layout_height="21dp"
                android:layout_marginStart="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginBottom="8dp"
                android:text="Artist"
                android:textAppearance="@style/TextAppearance.AppCompat.Body1"
                android:textColor="@color/colorSecondaryTextDefaultMaterialLight"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toStartOf="@+id/song_cost_layout_songlist"
                app:layout_constraintHorizontal_bias="1.0"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/video_title"
                app:layout_constraintVertical_bias="0.0" />


            <com.myAppName.Songplayer.Utils.AutoResizeTextView
                android:id="@+id/song_duration"
                android:layout_width="81dp"
                android:layout_height="14dp"
                android:layout_marginStart="8dp"
                android:layout_marginTop="32dp"
                android:layout_marginBottom="8dp"
                android:text="Duration"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.95"
                app:layout_constraintStart_toEndOf="@+id/uploader_username"
                app:layout_constraintTop_toBottomOf="@+id/song_cost_layout_songlist" />

            <ImageView
                android:id="@+id/download_indicator"
                android:layout_width="19dp"
                android:layout_height="15dp"
                android:layout_marginStart="8dp"
                android:layout_marginBottom="8dp"
                android:background="@drawable/song_download"
                android:visibility="gone"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent" />


            <ImageView
                android:id="@+id/download_complete_indicator"
                android:layout_width="19dp"
                android:layout_height="15dp"
                android:layout_marginStart="8dp"
                android:layout_marginBottom="8dp"
                android:background="@drawable/song_download_complete"
                android:visibility="gone"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent" />

            <android.support.constraint.ConstraintLayout
                android:id="@+id/song_cost_layout_songlist"
                android:layout_width="66dp"
                android:layout_height="17dp"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_marginTop="2dp"
                android:clickable="true"
                android:visibility="visible"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                tools:ignore="RelativeOverlap">

                <ImageView
                    android:id="@+id/imageView_dialog"
                    android:layout_width="33dp"
                    android:layout_height="match_parent"
                    android:layout_marginTop="2dp"
                    android:layout_marginBottom="2dp"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    app:layout_constraintVertical_bias="0.0"
                    app:srcCompat="@drawable/silver_star_selected" />

                <com.myAppName.Songplayer.Utils.AutoResizeTextView
                    android:id="@+id/your_stars_share_dialog"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentBottom="true"
                    android:layout_marginStart="2dp"
                    android:layout_marginTop="2dp"
                    android:layout_marginBottom="2dp"
                    android:text="2000"
                    android:textColor="@color/main_app_color"
                    android:textStyle="bold"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintStart_toEndOf="@+id/imageView_dialog"
                    app:layout_constraintTop_toTopOf="parent"
                    app:layout_constraintVertical_bias="0.428" />
            </android.support.constraint.ConstraintLayout>

        </android.support.constraint.ConstraintLayout>

    </android.support.v7.widget.CardView>

    <ImageView
        android:id="@+id/song_album_cover"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_marginTop="14dp"
        android:layout_marginStart="12dp"
        android:elevation="2dp"
        app:srcCompat="@drawable/no_cover_art"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

С левой стороны этого изображения вы можете увидеть результат, который я получаю, а справа - рисунок, который Android Studio's preview показывает мне:

enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...