AutoSizingTextView

107c7e4625bacbe78ee562359d89b318?s=47 Yuji Koketsu
November 28, 2017

 AutoSizingTextView

107c7e4625bacbe78ee562359d89b318?s=128

Yuji Koketsu

November 28, 2017
Tweet

Transcript

  1. AUTOSIZING TEXTVIEW

  2. HELLO ABOUT ME @kettsun0123

  3. AUTORESIZING TEXTVIEW AutosizingTextView

  4. WHAT IS AUTOSIZING TEXTVIEW? AUTOSIZING TEXTVIEW IS… ▸ Android O

    (API 26) ~ ▸ ϨΠΞ΢τʹ͋ͬͨϑΥϯταΠζΛ ࣗಈͰબఆͯ͘͠ΕΔ ▸ supportϥΠϒϥϦ΋͋ΔΑ
  5. AUTORESIZING TEXTVIEW ࢖͏ͱ͖ʹؾΛ͚ͭΔ͜ͱ

  6. AUTOSIZING TEXTVIEW 1. layout_̋̋=“wrap_content” 2. android:singleLine=“true”

  7. AUTOSIZING TEXTVIEW 1. layout_̋̋=“wrap_content” 2. android:singleLine=“true”

  8. AUTOSIZING TEXTVIEW layout_height=“wrap_content”

  9. AUTOSIZING TEXTVIEW

  10. AUTOSIZING TEXTVIEW layout_width=“wrap_content”

  11. AUTOSIZING TEXTVIEW

  12. AUTOSIZING TEXTVIEW

  13. AUTOSIZING TEXTVIEW if (mEllipsize != TextUtils.TruncateAt.MARQUEE) { // In a

    fixed-height view, so use our new text layout. if (mLayoutParams.height != LayoutParams.WRAP_CONTENT && mLayoutParams.height != LayoutParams.MATCH_PARENT) { autoSizeText(); invalidate(); return; } // Dynamic height, but height has stayed the same, // so use our new text layout. if (mLayout.getHeight() == oldht && (mHintLayout == null || mHintLayout.getHeight() == oldht)) { autoSizeText(); invalidate(); return; } } TextView.java > checkForRelayout()
  14. AUTOSIZING TEXTVIEW @Override protected void onLayout(boolean changed, int left, int

    top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); if (mDeferScroll >= 0) { int curs = mDeferScroll; mDeferScroll = -1; bringPointIntoView(Math.min(curs, mText.length())); } // Call auto-size after the width and height have been calculated. autoSizeText(); } TextView.java > onLayout(c, l, t, r, b)
  15. AUTOSIZING TEXTVIEW “wrap_content”

  16. AUTOSIZING TEXTVIEW 1. layout_̋̋=“wrap_content” 2. android:singleLine=“true”

  17. AUTOSIZING TEXTVIEW

  18. AUTOSIZING TEXTVIEW TextView.java > applySingleLine(s, a, c) private void applySingleLine(boolean

    singleLine, boolean applyTransformation, boolean changeMaxLines) { mSingleLine = singleLine; if (singleLine) { setLines(1); setHorizontallyScrolling(true); ɹɹɹɹ ...
  19. AUTORESIZING TEXTVIEW android:singleLine=“true”

  20. CONCLUSION 1. layout_̋̋=“wrap_content” 2. android:singleLine=“true”

  21. FIN Thanks:)