Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
iOS・Androidの文字サイズ設定をWebViewに!モバイルUIのアクセシビリティ...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
おしん
May 07, 2026
Technology
10
0
Share
iOS・Androidの文字サイズ設定をWebViewに!モバイルUIのアクセシビリティTips
フロントエンドカンファレンス名古屋 2026 でのLTで使用したスライドです。
おしん
May 07, 2026
More Decks by おしん
See All by おしん
モバイルアプリへのRemoteConfigの恩恵
shincarpediem
2
150
Swift UI デフォルト引数クイズ
shincarpediem
1
150
よりアプリらしさを出すために
shincarpediem
1
140
Concurrency Warningが 沢山出たから聞いてほしい ~Xcode 16.1 Beta 編~
shincarpediem
1
250
iOSのPhoto Libraryアクセス権限を見直してみよう
shincarpediem
1
250
SwiftUI登場前のVIPERアプリでもSwiftUIをスムーズに導入できた話
shincarpediem
3
1.8k
VIPERアプリにSwiftUIを導入してみた
shincarpediem
1
450
Other Decks in Technology
See All in Technology
Angular Architecture Revisited Modernizing Angular Architectural Patterns
rainerhahnekamp
0
100
Modernizing Your HCL Connections Experience: Visual Report to chain, Profile Enhancements, and AI Integration
wannesrams
0
190
VespaのParent Childを用いたフィードパフォーマンスの改善
taking
0
150
『生成AI時代のクレデンシャルとパーミッション設計 — Claude Code を起点に』の執筆企画
takuros
1
1.5k
社内エンジニア勉強会の醍醐味と苦しみ/tamadev
nishiuma
0
260
Arcana: Production-Ready RAG in Elixir @ ElixirConf EU 2026
georgeguimaraes
0
120
Agents CLI と Gemini Enterprise Agent Platform で マルチエージェント開発が楽しくなる!
kaz1437
0
190
AIが書いたコードを信じられない問題 〜レビュー負荷を下げるために変えたこと〜 / The AI Code Trust Gap: Reducing the Review Burden
bitkey
PRO
8
1.4k
The 7 pitfalls of AI
ufried
0
100
260422_Sansan_Tech_Talk__関西_vol.3_データ活用のリアル__矢田__.pdf
sansantech
PRO
0
140
色を視る
yuzneri
0
280
Hacobu Tech Deck
hacobu
PRO
0
140
Featured
See All Featured
Designing for humans not robots
tammielis
254
26k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
530
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
190
Building AI with AI
inesmontani
PRO
1
930
First, design no harm
axbom
PRO
2
1.2k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
770
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
Paper Plane (Part 1)
katiecoart
PRO
0
6.8k
Scaling GitHub
holman
464
140k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.3k
Writing Fast Ruby
sferik
630
63k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
61
43k
Transcript
モバイルUIのアクセシビリティTips おしん / @38Punkd iOS ・Android の 文字サイズ設定を WebView に!
・株式会社スタメン ・iOSエンジニア ・アプリネイティブ × WebViewの ハイブリッドアプリ開発に携わってきました おしん / @38Punkd
WebView だけ、文字サイズが固定になっていませんか? アプリネイティブ画面 OS 設定に追従 iOSの Dynamic Type や Androidのフォ
ントスケールに合わせて読みやすくなる WebView 画面 標準サイズのまま ユーザーが選んだ文字サイズが Webコンテンツだけ反映されない (特にiOSで) Web とネイティブの境界にあるため、対応漏れが起きやすい
文字サイズ設定は「特別対応」ではない iOS Android Android 14 以降は 最大200%のフォントスケーリングをサポート (従来は最大130%) OSの標準機能 対応工数に対して、UX
改善のインパクトが大きい領 域 出典: https://medium.com/airbnb-engineering/supporting-dynamic-type-at-airbnb- b47c68b0c998 3 割 文字サイズ調整を有効化している スマホユーザー
iOS WebView :実装のポイント ① CSS: body に-apple-system-body を指定 body {
font: -apple-system-body; /* iOS WebKit がサイズを 反映 */ } ② CSS: font-size は em 単位で指定 .title { font-size: 1.143em; } /* ✅ スケール する */ .description { font-size: 0.857em; } /* ✅ スケール する */ .bad-title { font-size: 16px; } /* ❌ 固定値 */ px 固定ではなく em を使うことで body のサイズ変化に追従 これだけで iOS WebKit が Dynamic Type の設定値を body のフォントサイズに反映
iOS ネイティブ:WebView リロード ③ Swift: Dynamic Type 変更を検知して WebView をリロード
NotificationCenter.default.addObserver( self, selector: #selector(dynamicTypeDidChange), name: UIContentSizeCategory.didChangeNotification, object: nil ) @objc private func dynamicTypeDidChange() { webView?.reload() // リロード後、CSS が新しいサイズで再評価される } UIContentSizeCategory.didChangeNotification を 受信したら WebView をリロードし CSSを再評価
Android :「対応できている風」に注意 文字が大きく見えても、実態は 文字だけのスケーリングではなく、Activity再生成とWebView全体ズームに 依存している場合があります 見た目 文字サイズ設定に追従しているように見える 実態 Activity 再生成でWebViewが作り直される
副作用 文字だけでなく画像・余白もズームされ得る リスク スクロール位置や入力中の状態が失われる可能性 がある → WebView WebView
Android ネイティブ:実装のポイント ① AndroidManifest: fontScale をconfigChanges に追加 <activity android:configChanges="fontScale|uiMode|density" ...
> Activity を再生成せず onConfigurationChanged で フォントスケール変化を受け取れるようにする ② Kotlin: WebSettings.setTextZoom(int) で反映 // 初期化 applyFontScale(resources.configuration.fontScale) override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) applyFontScale(newConfig.fontScale) } private fun applyFontScale(fontScale: Float) { webView.settings.textZoom = (fontScale * 100).roundToInt() } fontScale を検知し WebView 内のテキスト全体をスケールさせる
Android WebView :テキストは単位を問わずスケールされる ③ CSS:WebSettings.setTextZoom(int) の挙動 /* ✅ px 固定でも
setTextZoom でスケールされる */ .title { font-size: 16px; } /* ✅ em 相対でも同様にスケールされる */ .description { font-size: 0.75em; } /* ✅ rem 相対でも同様にスケールされる */ .caption { font-size: 0.75rem; } /* ⚠ テキスト以外(幅・高さ・余白)は変化しない */ .icon { width: 48px; height: 48px; } /* → スケールされない */ WebSettings.setTextZoom(int) は レンダリングエンジンレベルで適用されるため HTML/JS の変更は不要
iOS ・Android 実装仕様の比較 項目 iOS Android スケール変化の検知 UIContentSizeCategory .didChangeNotification onConfigurationChanged
( fontScale ) WebView への適用 CSS font: -apple-system-body WebSettings.setTextZoom(int) スケールする単位 em px ・ em ・ rem すべてスケールされる スケールしない単位/ 要素 px 固定・ rem (ルート基準のため) 幅・高さ・余白など 非テキスト要素
サンプルコード iOS https://github.com/shin- carpediem/DynamicTypeWebViewDemo Android https://github.com/shin- carpediem/AndroidDynamicTypeWebViewDemo