How do I tell if my textview has been ellipsized?

前端 未结 14 1682
天涯浪人
天涯浪人 2020-11-30 19:31

I have a multi-line TextView that has android:ellipsize=\"end\" set. I would like to know, however, if the string I place in there is actually too

14条回答
  •  孤街浪徒
    2020-11-30 20:00

    Really work so, for example, to pass full data to dialog from item of RecyclerView:

    holder.subInfo.post(new Runnable() {
                    @Override
                    public void run() {
                        Layout l = holder.subInfo.getLayout();
                        if (l != null) {
                            final int count = l.getLineCount();
                            if (count >= 3) {
                                holder.subInfo.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        final int c = holder.subInfo.getLineCount();
                                        if (c >= 3) {
                                            onClickToShowInfoDialog.showDialog(holder.title.getText().toString(), holder.subInfo.getText().toString());
                                        }
                                    }
                                });
                            }
                        }
                    }
                });
    

提交回复
热议问题