-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding a new line in auto completion view when the width of candidates is too big. #1173
Conversation
We will see this issue when using Zhuyin input (#1161) We are trying to fix this problem, and this can be reproduced when typing |
@@ -60,6 +62,8 @@ public AutoCompletionView(Context aContext, AttributeSet aAttrs, int aDefStyle) | |||
private void initialize(Context aContext) { | |||
inflate(aContext, R.layout.autocompletion_bar, this); | |||
mFirstLine = findViewById(R.id.autoCompletionFirstLine); | |||
mLineWidth = WidgetPlacement.dpDimension(getContext(), R.dimen.keyboard_width); | |||
mPerKeyWidth = WidgetPlacement.dpDimension(getContext(), R.dimen.keyboard_key_width); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am trying to get the correct line width from mFirstLine
, but it always returns zero from getWidth()
or getMeasuredWidth()
. R.dimen.keyboard_width
is not exactly correct because our real width should be the same with world_width
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MortimerGoro I am trying to use post runnable to make sure this UI has been loaded. but it still shows zero.
mFirstLine.post(() -> {
mLineWidth = mFirstLine.getWidth(); // the width is still not ready...
});
Alternatively, R.dimen.world_width
is more close to the correct result.
07bae24
to
35d445b
Compare
@@ -60,6 +62,8 @@ public AutoCompletionView(Context aContext, AttributeSet aAttrs, int aDefStyle) | |||
private void initialize(Context aContext) { | |||
inflate(aContext, R.layout.autocompletion_bar, this); | |||
mFirstLine = findViewById(R.id.autoCompletionFirstLine); | |||
mLineWidth = WidgetPlacement.pixelDimension(getContext(), R.dimen.world_width); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not correct to use the world width here. Ideally the View should get the current view width and detect layout changes. You can override onSizeChanged
in order to detect the size and layout of the whole view: https://developer.android.com/reference/android/view/View.html#onSizeChanged%28int,%20int,%20int,%20int%29
I'll wait for the review comment to be addressed before landing this one. |
29bdac0
to
abb3dcf
Compare
abb3dcf
to
5d1af4e
Compare
I decide to add |
@@ -103,6 +103,7 @@ | |||
<dimen name="no_internet_z_distance" format="float" type="dimen">2.5</dimen> | |||
|
|||
<!-- Autocompletion Widget --> | |||
<dimen name="autocompletion_widget_line_width">530dp</dimen> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some keyboards will have a different width so this value won't match and the ideal thing is detect onResize changes. Anyway it will work for chinese keyboard for now, as it size is fixed and only them have the autocompletion. We can implement the better solution in a follow-up, please create a issue for it
No description provided.