0

現在、さまざまな画面サイズでのアプリの表示を改善する作業を行っています。この TextView は、ビューの最後まで拡張する必要があります。これは機能しますが、問題は、この見苦しい半直線が表示されることです。私はすでに他のマージンとパディングを設定しましたが、これはあるデバイスまたは別のデバイスで見栄えが悪くなったので、どこでも正しく見えるようにする良い解決策があるかどうかを自問していました. これは、対応する TextView です。

<TextView
    android:id="@+id/text3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/relative_layout"
    android:layout_marginBottom="5dp"
    android:layout_marginTop="5dp"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:maxLines="100"
    android:ellipsize="end"
    android:textSize="18sp"
    android:clickable="true"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textIsSelectable="false"/>

これが現在の外観です

誰かが私を助けることができれば、それは素晴らしいことです、事前に感謝します!

4

1 に答える 1

0

次のような AdaptingTextView を作成しました。

public class AdaptingTextView extends TextView {

public AdaptingTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}

public AdaptingTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}

public AdaptingTextView(Context context) {
super(context);
}

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);

// set fitting lines to prevent cut text
int fittingLines = h / this.getLineHeight();
if (fittingLines > 0) {
    this.setLines(fittingLines);
}
}
}

ソース: https://stackoverflow.com/a/26998769/3272495

于 2015-11-25T17:23:13.643 に答える