diff options
| author | Seigo Nonaka <nona@google.com> | 2016-04-20 15:45:34 +0900 |
|---|---|---|
| committer | Seigo Nonaka <nona@google.com> | 2016-04-22 19:06:53 +0900 |
| commit | 77972bbf2cc65a8ea961e3a1b84b4f631b87fdb8 (patch) | |
| tree | ac3b091b77ce3eaf3342eee3dbbb1f36cb49492c /core/java/android | |
| parent | 0fb51357afb64a034a59f68a926f79d18213c72c (diff) | |
Fix unexpected truncation again.
Unexpected truncation happens again after [1].
This is fixed by setting match_parent into the container LinearLayout.
For the unexpected truncation of Holo Theme is came from other but
related root cause. To calculate the window and container width,
need to add container padding in addition to the maximum width of
the text view. Otherwise the width of the container view will be
shrunk and the contents will be truncated. This only happens on
Holo Theme since the padding of the container is zero on Material
Theme.
I manually confirmed this CL doesn't revive following issues
- 28034210
- 27341560
[1]: I67886a752ef110d3433dddd6aa8447a9027f8e19
[2]: I69b258687b4bf5510d9b2c3e690c88106bf893f5
Bug: 28266493
Bug: 28281740
Change-Id: Ie6d274714ac08080dc22aeb8ecd8b7729cb634cd
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/widget/Editor.java | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 440ef2162fc5..d6e892e7549c 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -3251,6 +3251,7 @@ public class Editor { private final SuggestionSpanInfo mMisspelledSpanInfo = new SuggestionSpanInfo(); private int mContainerMarginWidth; private int mContainerMarginTop; + private LinearLayout mContainerView; private class CustomPopupWindow extends PopupWindow { @Override @@ -3288,20 +3289,19 @@ public class Editor { protected void initContentView() { final LayoutInflater inflater = (LayoutInflater) mTextView.getContext(). getSystemService(Context.LAYOUT_INFLATER_SERVICE); - final ViewGroup relativeLayout = (ViewGroup) inflater.inflate( + mContentView = (ViewGroup) inflater.inflate( mTextView.mTextEditSuggestionContainerLayout, null); - final LinearLayout suggestionWindowContainer = - (LinearLayout) relativeLayout.findViewById( - com.android.internal.R.id.suggestionWindowContainer); + mContainerView = (LinearLayout) mContentView.findViewById( + com.android.internal.R.id.suggestionWindowContainer); ViewGroup.MarginLayoutParams lp = - (ViewGroup.MarginLayoutParams) suggestionWindowContainer.getLayoutParams(); + (ViewGroup.MarginLayoutParams) mContainerView.getLayoutParams(); mContainerMarginWidth = lp.leftMargin + lp.rightMargin; mContainerMarginTop = lp.topMargin; mClippingLimitLeft = lp.leftMargin; mClippingLimitRight = lp.rightMargin; - mSuggestionListView = (ListView) relativeLayout.findViewById( + mSuggestionListView = (ListView) mContentView.findViewById( com.android.internal.R.id.suggestionContainer); mSuggestionsAdapter = new SuggestionAdapter(); @@ -3314,9 +3314,7 @@ public class Editor { mSuggestionInfos[i] = new SuggestionInfo(); } - mContentView = relativeLayout; - - mAddToDictionaryButton = (TextView) relativeLayout.findViewById( + mAddToDictionaryButton = (TextView) mContentView.findViewById( com.android.internal.R.id.addToDictionaryButton); mAddToDictionaryButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { @@ -3349,7 +3347,7 @@ public class Editor { } }); - mDeleteButton = (TextView) relativeLayout.findViewById( + mDeleteButton = (TextView) mContentView.findViewById( com.android.internal.R.id.deleteButton); mDeleteButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { @@ -3461,7 +3459,8 @@ public class Editor { mDeleteButton.measure(horizontalMeasure, verticalMeasure); width = Math.max(width, mDeleteButton.getMeasuredWidth()); - width += mContainerMarginWidth; + width += mContainerView.getPaddingLeft() + mContainerView.getPaddingRight() + + mContainerMarginWidth; // Enforce the width based on actual text widths mContentView.measure( |
