私はこれに1週間以上苦労し、ついにこれを機能させる方法を見つけました!
私の問題は、すべてが「ブロック」としてスクロールすることでした。テキスト自体はスクロールしていましたが、行ごとではなくチャンクとしてでした。これは明らかに私にはうまくいきませんでした。なぜなら、下部の線が途切れるからです。以前の解決策のすべてが私にはうまくいかなかったので、私は自分で作りました。
これがはるかに簡単な解決策です:
パッケージ内に「PerfectScrollableTextView」というクラスファイルを作成し、このコードをコピーして次の場所に貼り付けます。
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.TextView;
public class PerfectScrollableTextView extends TextView {
public PerfectScrollableTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setVerticalScrollBarEnabled(true);
setHorizontallyScrolling(false);
}
public PerfectScrollableTextView(Context context, AttributeSet attrs) {
super(context, attrs);
setVerticalScrollBarEnabled(true);
setHorizontallyScrolling(false);
}
public PerfectScrollableTextView(Context context) {
super(context);
setVerticalScrollBarEnabled(true);
setHorizontallyScrolling(false);
}
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
if(focused)
super.onFocusChanged(focused, direction, previouslyFocusedRect);
}
@Override
public void onWindowFocusChanged(boolean focused) {
if(focused)
super.onWindowFocusChanged(focused);
}
@Override
public boolean isFocused() {
return true;
}
}
最後に、XMLで「TextView」を変更します。
から:<TextView
に:<com.your_app_goes_here.PerfectScrollableTextView