Я пишу какой-то мессенджер для Android, и теперь я сталкиваюсь с проблемой: я думаю об изменении состояния сообщения с непрочитанного на чтение, когда «Сообщение видно пользователю». Сообщение является подклассом RelativeLayout
, сообщения организованы в вертикальное расположение с прокруткой, которая может быть длинной, поэтому мне нужно видимое событие или что-то подобное.
Я нашел метод void View.onDisplayHint(int hint)
, но в документах написано
Приложения не должны полагаться на этот совет, поскольку нет гарантии, что они его получат.
Любые предложения, как поймать видимость изменения пользователя?
UPD: при необходимости код макета
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:weightSum="1"
android:layout_height="fill_parent" android:orientation="vertical"
android:id="@+id/conversation_main_layout">
<RelativeLayout android:layout_height="wrap_content"
android:id="@+id/relativeLayoutHeader" android:layout_width="fill_parent"
android:background="@drawable/header_background_selector"
android:padding="3px">
<Button style="@style/header_button"
android:layout_alignParentRight="true" android:text="@string/conversation_right_button"
android:id="@+id/buttonCall"></Button>
<Button style="@style/header_button" android:text="@string/conversation_left_button"
android:layout_alignParentLeft="true" android:id="@+id/buttonInfo"></Button>
<TextView android:layout_width="wrap_content" android:text="@string/conversation_header"
android:layout_centerVertical="true" android:layout_centerHorizontal="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/textViewContactName" android:layout_height="wrap_content"></TextView>
</RelativeLayout>
<ScrollView android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_margin="3dip"
android:scrollbars="none">
<LinearLayout android:id="@+id/linearLayoutDataHolder"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
</ScrollView>
</LinearLayout>