MZCretin / ExpandableTextView

实现类似微博内容,@用户,链接高亮,@用户和链接可点击跳转,可展开和收回的TextView
1.41k stars 164 forks source link

不知道为什么,我在recyclerview里使用没有效果,就和普通textview一样了 #51

Closed zaaach closed 4 years ago

zaaach commented 4 years ago

recyclerview的item布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:paddingBottom="@dimen/dp_6"
    android:orientation="vertical">

    <include layout="@layout/include_home_module_item_feed_user_info_card" />

    <LinearLayout
        android:id="@+id/ll_timeline_body_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingStart="@dimen/layout_padding_left"
        android:paddingEnd="@dimen/layout_padding_right">

        <include layout="@layout/include_feed_text_body" />

    </LinearLayout>

    <include layout="@layout/include_timeline_tool_bar" />

    <include layout="@layout/include_timeline_hot_comment" />
</LinearLayout>

@layout/include_feed_text_body

<merge xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:showIn="@layout/item_feed_list_only_text">

    <TextView
        android:id="@+id/tv_timeline_body_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:text="雨向往的向日葵"
        android:textColor="@color/gray_darker"
        android:textSize="@dimen/size_14sp" />

    <com.ctetin.expandabletextviewlibrary.ExpandableTextView
        android:id="@+id/tv_timeline_body_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/dp_4"
        android:textSize="@dimen/size_13sp"
        android:textColor="@color/gray_moderate"
        android:lineSpacingExtra="@dimen/dp_3"
        app:ep_need_contract="true"
        app:ep_expand_text="全文"
        app:ep_expand_color="@color/theme_color"
        app:ep_link_color="@color/blue_deep"
        app:ep_need_link="true"
        app:ep_need_expand="true"
        app:ep_max_line="4"
        app:ep_need_mention="true"
        app:ep_mention_color="@color/theme_color"
        app:ep_contract_text="收起"/>
</merge>
MZCretin commented 4 years ago

你是怎么给View赋值的

zaaach commented 4 years ago

我瞎了,原来是用setContent()这个方法设置文本,代码里用了setText()。。。