WAI
Status Update
Comments
ya...@gmail.com <ya...@gmail.com> #2
Take note that, https://play.google.com/store/apps/details?id=com.google.android.keep&hl=en (Google Keep), which android:targetSdkVersion 28 inherits same problem. If you create a new note, and type using non English, you will observe the line after input being pushed down.
vi...@google.com <vi...@google.com>
vi...@google.com <vi...@google.com> #3
Thank you for reporting this issue. For us to further investigate this issue, please provide the following additional information:
Please provide sample project or apk to reproduce the issue.
Also mention the steps to be followed for reproducing the issue with the given sample project or apk.
Expected output
What is the expected output?
Current output
What is the current output?
Note: We could notice the issue in Google keep application as provided in comment #2 .
The line spacing differs in English, Japanese and Chinese languages.
Please don't mind the words typed in Japanese and Chinese as they are randomly typed and also we don't know reading / writing Japanese and Chinese.
Please provide sample project or apk to reproduce the issue.
Also mention the steps to be followed for reproducing the issue with the given sample project or apk.
Expected output
What is the expected output?
Current output
What is the current output?
Note: We could notice the issue in Google keep application as provided in
The line spacing differs in English, Japanese and Chinese languages.
Please don't mind the words typed in Japanese and Chinese as they are randomly typed and also we don't know reading / writing Japanese and Chinese.
ya...@gmail.com <ya...@gmail.com> #4
I included the complete source code to reproduce the problem.
https://github.com/yccheok/bug-131284662
Folder API28 - Demonstrate the line spacing bug occurs in API 28
Folder API27 - Demonstrate the line spacing bug doesn't occur in API 27
Please kindly look at README.md for the outcome.
Please kindly let me know, if you need additional information.
Thank you.
Folder API28 - Demonstrate the line spacing bug occurs in API 28
Folder API27 - Demonstrate the line spacing bug doesn't occur in API 27
Please kindly look at README.md for the outcome.
Please kindly let me know, if you need additional information.
Thank you.
ya...@gmail.com <ya...@gmail.com> #5
Take note that, Same problem occurs regardless on whether you are using androidx.appcompat.widget.AppCompatEditText or android.widget.EditText
vi...@google.com <vi...@google.com> #6
Thank you for reporting this issue. We have shared this with our product and engineering team and will update this issue with more information as it becomes available.
vi...@google.com <vi...@google.com> #7
This is expected behavior. Until the different font is entered the system is not aware of the Japanese text line height. Therefore when the user starts to enter Japanese text, the expected line height changes.
If you want to keep the line height the same (which might introduce overlapping glyph in different lines) please set fallbackLineSpacing to false.
https://developer.android.com/reference/android/widget/TextView.html#attr_android:fallbackLineSpacing
If you want to keep the line height the same (which might introduce overlapping glyph in different lines) please set fallbackLineSpacing to false.
ya...@gmail.com <ya...@gmail.com> #8
Thanks for telling about "fallbackLineSpacing". May I know, why such behaviour doesn't occur in API 27?
Description
Version used: 28
Theme used: Theme.AppCompat.Light.DarkActionBar
Devices/Android versions reproduced on: Emulator Nexus 5 API 28
We notice that, during targetSdkVersion 28, androidx.appcompat.widget.AppCompatEditText will tend to "slightly push down" the line after input, when non-English unicode (Like Chinese, Japanese, ...) is being entered.
Such behavior doesn't happen, when the code is targetSdkVersion 27 or below.
Use targetSdkVersion 27, run on emulator API 28
======================================
(Before input non-English unicode) - before-27.png
(After input non-English unicode) - after-27.png
(Confirm spacing is OK) - compare-27.png
Use targetSdkVersion 28, run on emulator API 28
======================================
(Before input non-English unicode) - before-28.png
(After input non-English unicode) - after-28.png
(Confirm spacing is problematic. Lines after input are being pushed down) - compare-28.png
This is the XML and code used by us. We inherit from `androidx.appcompat.widget.AppCompatEditText`, to paint the lines, to make the problem more obvious.
<com.yocto.wenote.note.LinedEditText
android:id="@+id/body_edit_text"
android:gravity="top"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:layout_marginBottom="12dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:scrollbars="vertical"
android:textSize="18sp"
android:singleLine="false"
android:lineSpacingMultiplier="1.4"
android:inputType="textMultiLine|textCapSentences"
android:textCursorDrawable="?attr/shorterCursor" />
package com.yocto.wenote.note;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.TypedValue;
import com.yocto.wenote.R;
/**
* Created by yccheok on 24/3/2018.
*/
public class LinedEditText extends androidx.appcompat.widget.AppCompatEditText {
private final Paint mPaint = new Paint();
private int noteLineColor;
private static final float DEFAULT_LINE_SPACING_EXTRA = 0.0f;
private static final float DEFAULT_LINE_SPACING_MULTIPLIER = 1.4f;
private void initResource() {
Context context = getContext();
TypedValue typedValue = new TypedValue();
Resources.Theme theme = context.getTheme();
theme.resolveAttribute(R.attr.noteLineColor, typedValue, true);
noteLineColor = typedValue.data;
}
public LinedEditText(Context context) {
super(context);
initResource();
initPaint();
}
public void setNoteLineColor(int noteLineColor) {
this.noteLineColor = noteLineColor;
}
public LinedEditText(Context context, AttributeSet attrs) {
super(context, attrs);
initResource();
initPaint();
}
public LinedEditText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initResource();
initPaint();
}
private void initPaint() {
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setColor(noteLineColor);
mPaint.setStrokeWidth(1);
}
@Override
protected void onDraw(Canvas canvas) {
int left = getLeft();
int right = getRight();
int paddingTop = getPaddingTop();
int paddingBottom = getPaddingBottom();
int paddingLeft = getPaddingLeft();
int paddingRight = getPaddingRight();
final int heightWithScrollY = getHeight() + getScrollY();
int lineHeight = getLineHeight();
int count = (heightWithScrollY-paddingTop-paddingBottom) / lineHeight;
mPaint.setColor(noteLineColor);
mPaint.setTypeface(this.getTypeface());
final float originalLineHeight;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
originalLineHeight = lineHeight / getLineSpacingMultiplier();
} else {
originalLineHeight = lineHeight / DEFAULT_LINE_SPACING_MULTIPLIER;
}
for (int i = 0; i < count; i++) {
float baseline = lineHeight * (i + 1) + paddingTop - mPaint.descent() - (lineHeight - originalLineHeight);
canvas.drawLine(
left + paddingLeft,
baseline,
right - paddingRight,
baseline,
mPaint
);
}
super.onDraw(canvas);
}
//
@Override
protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
super.onTextChanged(text, start, lengthBefore, lengthAfter);
if (lengthBefore != lengthAfter) {
float add;
float mul;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
add = getLineSpacingExtra();
mul = getLineSpacingMultiplier();
} else {
add = DEFAULT_LINE_SPACING_EXTRA;
mul = DEFAULT_LINE_SPACING_MULTIPLIER;
}
setLineSpacing(0f, 1f);
setLineSpacing(add, mul);
}
}
}
Take note that, if you use `targetSdkVersion` 28, BUT run on emulator API 27, this problem will not occur too.
This issue also posted at
Thank you.