TextView 显示多行文本时只显示了3行的问题


    android:id="@+id/text_one"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
/>

    android:id="@+id/text_two"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ellipsize="marquee"
    android:singleLine="true"
/>
mTextOne = (TextView) v.findViewById(R.id.text_one);
mTextTwo = (TextView) v.findViewById(R.id.text_two);

mTextOne.addOnLayoutChangeListener(new OnLayoutChangeListener() {
    @Override
    public void onLayoutChange(View v, int left, int top, int right,
            int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
        if (mTextOne.getLineCount() > 4) {
            int start = mTextOne.getLayout().getLineStart(3);
            String twoText = mTextOne.getText().toString().substring(start);
            mTextTwo.setText(twoText);
            mTextOne.setMaxLines(3);
        }
    }
});

你可能感兴趣的:(TextView 显示多行文本时只显示了3行的问题)