Skip to content
Snippets Groups Projects
Commit eeafd429 authored by Chet Haase's avatar Chet Haase
Browse files

Fix NumberPicker text positioning.

NumberPicker was making incorrect assumptions about how text was
positioned and centered inside of its controls. This fix changes
the logic of how the scroll wheel draws its text items based on where
the text is positioned inside the EditText that displays the text
by default. This should ensure that the text of the scroll wheel
exactly overlays the text in the EditText view.

Change-Id: I4a7694931f19042bd4142232612490c2ab912d11
parent 45add1ab
No related branches found
No related tags found
No related merge requests found
......@@ -1208,7 +1208,10 @@ public class NumberPicker extends LinearLayout {
float textGapCount = selectorIndices.length - 1;
int selectorTextGapHeight = (int) (totalTextGapHeight / textGapCount + 0.5f);
mSelectorElementHeight = mTextSize + selectorTextGapHeight;
mInitialScrollOffset = mTextSize - 3 * (mSelectorElementHeight % 2);
// Ensure that the middle item is positioned the same as the text in mInputText
int editTextTextPosition = mInputText.getBaseline() + mInputText.getTop();
mInitialScrollOffset = editTextTextPosition -
(mSelectorElementHeight * SELECTOR_MIDDLE_ITEM_INDEX);
mCurrentScrollOffset = mInitialScrollOffset;
updateInputTextView();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment