layout_alignRight не работает должным образом - PullRequest
0 голосов
/ 30 апреля 2018

Может ли кто-нибудь помочь мне создать пользовательский интерфейс, как указано ниже. Я сталкиваюсь с одной проблемой при создании ниже Ui. Когда текст маленький, значок справа внизу не отображается. Пожалуйста помоги.

Вот код.

<FrameLayout
    android:id="@+id/attachmentViewFL"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/imageView"
    android:background="@drawable/chat_bg_incoming"
    android:padding="5dp"
    >

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <RelativeLayout
            android:id="@+id/attachmentRL"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
          >

            <RelativeLayout
                android:id="@+id/nonThumbnailRL"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="visible">

                <ImageView
                    android:id="@+id/attachmentIV"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerInParent="true"
                    android:paddingRight="5dp"
                    android:paddingTop="5dp"
                    android:src="@drawable/extension_type_unknown" />

                <TextView
                    android:id="@+id/textView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_toLeftOf="@+id/progressBarRL"
                    android:layout_toRightOf="@id/attachmentIV"
                    android:text="text test  okay"
                    android:textColor="@color/dark_grey_font"
                    android:textIsSelectable="false"
                    android:textSize="16sp" />

            </RelativeLayout>
        </RelativeLayout>

        <TextView
            android:layout_below="@id/attachmentRL"
            android:layout_marginTop="5dp"
            android:id="@+id/rowChatMessageTimeTV"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            android:text="oct 20, 10:25 AM"
            android:textColor="@color/grey_font_dark"
            android:textSize="12sp" />
        <ImageView
            android:id="@+id/rowChatMessageStatus"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/attachmentRL"
            android:layout_marginTop="5dp"
            android:scaleType="fitEnd"
            android:layout_marginLeft="5dp"
            android:layout_alignRight="@id/attachmentRL"
            android:layout_toRightOf="@id/rowChatMessageTimeTV"

            android:src="@drawable/ic_read_msg" />

    </RelativeLayout>
</FrameLayout> 

Если текст маленький, значок ic_read_msg не отображается. Но если текст достаточно большой, он отображается правильно, так как я ожидаю его отображения. Я не хочу использовать android:layout_alignParentRight="true", так как он всегда выбирает вид справа и соответствует ширине экрана.

1 Ответ

0 голосов
/ 30 апреля 2018

Попробуйте удалить android:layout_alignRight="@id/attachmentRL из ImageView.

<ImageView
            android:id="@+id/rowChatMessageStatus"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/attachmentRL"
            android:layout_marginTop="5dp"
            android:scaleType="fitEnd"
            android:layout_marginLeft="5dp"
            android:layout_alignRight="@id/attachmentRL" // ---> Remove this line
            android:layout_toRightOf="@id/rowChatMessageTimeTV"
            android:src="@drawable/ic_read_msg" />
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...