最初のレイアウト 私はので、これは単にリスト項目であるようにするためです <のLinearLayoutのxmlns:アンドロイド= "http://schemas.android.com/apk/res/android" アンドロイド:オリエンテーション= "縦" のandroid:layout_width = "match_parent" アンドロイド:layout_height = "match_parent"> <RelativeLayout アンドロイド:layout_marginBottom = "10dp" アンドロイド:layout_width = "match_parent" アンドロイド:layout_height = "wrap_content" アンドロイド:layout_marginLeft = "25dp" アンドロイド:layout_marginRight = "25dp" アンドロイド:背景= "@描画可能/ rounded_box"> <TextViewの アンドロイド:ID = "@ + ID / tv_date" アンドロイド:layout_width = "match_parent" アンドロイド:layout_height = "wrap_content" アンドロイド:layout_marginLeft = "17dp" アンドロイド:layout_marginTop = "8DP" アンドロイド:テキスト=「日付」 アンドロイド:の、textColor = "#ff333333" アンドロイド:TEXTSIZE = "13sp" /> <TextViewの //最も重要な行の表示を設定します アンドロイド:MAXLINES = "3" アンドロイド:ID = "@ + ID / tv_text" アンドロイド:layout_width = "wrap_content" アンドロイド:layout_height = "wrap_content" アンドロイド:layout_below = "ID / tv_date @" アンドロイド:layout_alignLeft = "ID / tv_date @" アンドロイド:layout_marginTop = "10dp" アンドロイド:layout_marginBottom = "10dp" アンドロイド:テキスト=「テキスト」 アンドロイド:の、textColor = "#ff333333" アンドロイド:TEXTSIZE = "13sp" /> <のLinearLayout アンドロイド:ID = "@ + ID / ll_img" アンドロイド:layout_marginBottom = "10dp" アンドロイド:layout_marginLeft = "17dp" アンドロイド:layout_below = "ID / tv_text @" アンドロイド:オリエンテーション=「横」 アンドロイド:layout_width = "match_parent" アンドロイド:layout_height = "wrap_content"> <ImageViewの アンドロイド:layout_marginRight = "15dp" アンドロイド:ID = "@ + ID / iv_img1" アンドロイド:layout_width = "wrap_content" アンドロイド:layout_height = "wrap_content" /> <ImageViewの アンドロイド:layout_marginRight = "15dp" アンドロイド:ID = "@ + ID / iv_img2" アンドロイド:layout_width = "wrap_content" アンドロイド:layout_height = "wrap_content" /> <ImageViewの アンドロイド:ID = "@ + ID / iv_img3" アンドロイド:layout_width = "wrap_content" アンドロイド:layout_height = "wrap_content" /> </のLinearLayout> <ImageViewの アンドロイド:ID = "@ + ID / iv_more" アンドロイド:可視=「ゴーン」 アンドロイド:layout_marginTop = "10dp" アンドロイド:layout_marginBottom = "5DP" アンドロイド:layout_below = "@ + ID / ll_img" アンドロイド:layout_centerHorizontal = "true" を アンドロイド:SRC = "@ミップマップ/もっと" アンドロイド:layout_width = "17dp" アンドロイド:layout_height = "12dp" /> </ RelativeLayout> </のLinearLayout> // Java実装ロジック //テキスト表示または非表示には、3行を超えた後に決定 プライベートブールフラグ=真; ((ViewHolderTitle)ホルダー).tv_text.getViewTreeObserver()。addOnGlobalLayoutListener(新しいViewTreeObserver.OnGlobalLayoutListener(){ @オーバーライド ます。public void onGlobalLayout(){ IF(((ViewHolderTitle)ホルダー).tv_text.getLineCount()> = 3){ ((ViewHolderTitle)ホルダー).iv_more.setVisibility(View.VISIBLE)。 } そうしないと { ((ViewHolderTitle)ホルダー).iv_more.setVisibility(View.GONE)。 } } }); ((ViewHolderTitle)ホルダー).iv_more.setOnClickListener(新しいView.OnClickListener(){ @オーバーライド 公共のボイドのonClick(ビュービュー){ IF(フラグ){ フラグ= falseは、 //上矢印画像 ((ViewHolderTitle)ホルダー).iv_more.setImageResource(R.mipmap.more)。 ((ViewHolderTitle)ホルダー).tv_text.setEllipsize(NULL); //展開 ((ViewHolderTitle)ホルダー).tv_text.setMaxLines(Integer.MAX_VALUEの); //ディスプレイの行数がのTextViewをキャンセル ((ViewHolderTitle)ホルダー).tv_text.setSingleLine(偽); //このメソッドは、そうでない場合は、あなたが展開できない、設定する必要があります } そうしないと { フラグが真=。 //下矢印ピクチャー ((ViewHolderTitle)ホルダー).iv_more.setImageResource(R.mipmap.more_open)。 ((ViewHolderTitle)ホルダー).tv_text.setEllipsize(TextUtils.TruncateAt.END)。//收缩 ((ViewHolderTitle)ホルダー).tv_text.setMaxLines(3)。 } } });