Share
Embed
Annual Pro sale · Save $30
Have presentations of your own?
Share with private links, password protection, and more control over your work.
Transcript
89 slides
-
Overview •Android Text Rendering •Typography and Android •Internationalization and Localization
•Localize All the Androids -
Imaginary line which a line of text rests upon Baseline
getBaseline(); getLineBounds(0, null); getLineBounds(1, null); -
Imaginary line which a line of text rests upon Baseline
getBaseline(); getLineBounds(0, null); getLineBounds( -
Baseline getBaseline(); getLineBounds(0, null); public final int getLineBaseline(int line) {
// getLineTop(line+1) == getLineTop(line) return getLineTop(line+1) - getLineDescent(line); } -
Imaginary line which a line of text rests upon Baseline
getBaseline(); getLineBounds(0, null); getLineBounds( -
Imaginary line which a line of text rests upon Baseline
getBaseline() getLineBounds( getLineBounds(1, null); -
Imaginary line running along the top of non-ascending, lowercase letters
Meanline No Known Android API -
The invisible line marking the farthest distance between the baseline
and the top of the glyph. Ascent Line textView.getPaint().ascent() -
textView.getPaint().ascent() /** * Return the distance above (negative) the baseline
(ascent) based on the * current typeface and text size. * * @return the distance above (negative) the baseline (ascent) based on the * current typeface and text size. */ Ascent Line -
textView.getPaint() .getFontMetrics().top The invisible line marking the farthest distance between
the baseline and the top of the glyph. Ascent Line -
/** * The maximum distance above the baseline for the
tallest glyph in * the font at a given text size. */ textView.getPaint().getFontMetrics().top Ascent Line -
The invisible line marking the lowest point of the descenders
within a font. Descender Line textView.getPaint().descent() -
textView .getPaint() .getFontMetrics().bottom The invisible line marking the lowest point
of the descenders within a font. Descender Line -
The spacing between the baselines of each line of text
Leading textView .setLineSpacing(add,mult); “Multiple people defending fragment API and behavior pretty hard around the internet lately. Enjoy your straw houses, little pigs.” “Multiple people defending fragment API and behavior pretty hard around the internet lately. Enjoy your straw houses, little pigs.” -
The spacing between the baselines of each line of text
Leading textView .setLineSpacing(add,mult); Add: pixels added to each line height “Multiple people defending fragment API and behavior pretty hard around the internet lately. Enjoy your straw houses, little pigs.” “Multiple people defending fragment API and behavior pretty hard around the internet lately. Enjoy your straw houses, little pigs.” -
The spacing between the baselines of each line of text
Leading textView .setLineSpacing(add,mult); Add: pixels added to each line height Mult: float to multiply each line height by. Initially 1.0 “Multiple people defending fragment API and behavior pretty hard around the internet lately. Enjoy your straw houses, little pigs.” “Multiple people defending fragment API and behavior pretty hard around the internet lately. Enjoy your straw houses, little pigs.” -
Internationalization Design a product from the ground up to be
easily localizable -
Localization The act of making a product meet language and
cultural requirements for a locale*. -
Locale in Android Locale.class getDefault() Returns the users preferred locale
getDisplayLanguage() Get language name for default Locale getDisplayCountry() Get country name for default Locale -
1.Identify target languages and locales 2.Design for localization 3.Manage Strings
for localization 4.Translate UI Strings and other resources 5.Test your localized app 6.Prepare for localized app 7.Support international users after launch Google Localization Checklist -
1.Identify target languages and locales 2.Design for localization (and develop
your layouts using proper localization standards) 3.Manage Strings for localization 4.Translate UI Strings and other resources 5.Test your localized app 6.Prepare for localized app 7.Support international users after launch Google Localization Checklist -
Google Localization Checklist 1.Identify target languages and locales 2.Design for
localization (and develop your layouts using proper localization standards) 3.Manage Strings for localization 4.Translate UI Strings and other resources 5.Test your localized app 6.Prepare for localized app 7.Support international users after launch -
1.Support RTL 2.Make font file a localized String Elliott’s Development
Localization Checklist -
private void loadCustomFont(Context context, AttributeSet attrs) { TypedArray typedArray =
context.obtainStyledAttributes(attrs, R.styleable.DebugTextView); String fontLocation = typedArray.getString(R.styleable.DebugTextView_font); Typeface customTypeFace = Typeface.createFromAsset(getContext().getAssets(), fontLocation); super.setTypeface(customTypeFace); } CustomTextView.java Cache in memory Fonts -
Fonts public DebugTextView(Context context, AttributeSet attrs) { super(context, attrs); loadCustomFont(context,attrs);
} CustomTextView.java Do for all constructors -
1.Support RTL 2.Make font file a localized String 3.Mind font
padding Elliott’s Development Localization Checklist -
<com.omitneedlesscode.droidconnyc.DebugTextView android:text="@string/test_string" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/example_text_view" style="@style/localized_text_view" android:includeFontPadding="false" android:textSize="28sp"/> Don’t set
include font padding to false Font Padding -
<com.omitneedlesscode.droidconnyc.DebugTextView android:text="@string/test_string" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/example_text_view" style="@style/localized_text_view" android:includeFontPadding="false" android:textSize="28sp"/> Don’t set
include font padding to false Font Padding -
<com.omitneedlesscode.droidconnyc.DebugTextView android:text="@string/test_string" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/example_text_view" style="@style/localized_text_view" android:includeFontPadding="false" android:textSize="28sp"/> Don’t set
include font padding to false Font Padding -
1.Support RTL 2.Make font file a localized String 3.Mind font
padding 4.One layout to rule them all Elliott’s Development Localization Checklist -
“In cases where your UI can't accommodate text in one
of your target languages, you can create an alternative layout for that language only.” Google Localization Checklist https://developer.android.com/distribute/tools/localization-checklist.html One Layout -
“In cases where your UI can't accommodate text in one
of your target languages, you can create an alternative layout for that language only.” “While the flexibility of alternative layouts exists it can also make your apps harder to maintain over time. In general, using a single, more flexible layout is preferred.” Google Localization Checklist https://developer.android.com/distribute/tools/localization-checklist.html One Layout -
“In cases where your UI can't accommodate text in one
of your target languages, you can create an alternative layout for that language only.” “While the flexibility of alternative layouts exists it can also make your apps harder to maintain over time. In general, using a single, more flexible layout is preferred.” Google Localization Checklist https://developer.android.com/distribute/tools/localization-checklist.html One Layout -
<Layout> <com.omitneedlesscode.droidconnyc.DebugTextView android:text="@string/test_string" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/example_text_view" android:layout_marginStart="20dp" android:layout_marginEnd="20dp" android:textSize=“28sp"/> </Layout>
<Layout> <com.omitneedlesscode.droidconnyc.DebugTextView android:id="@+id/example_text_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="20dp" android:layout_marginLeft="20dp" android:text="@string/test_string" android:textSize=“28sp"/> </Layout> API 17+ API <17 One Layout -
<Layout> <com.omitneedlesscode.droidconnyc.DebugTextView android:text="@string/test_string" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/example_text_view" android:layout_marginStart="20dp" android:layout_marginEnd="20dp" android:textSize=“28sp"/> </Layout>
<Layout> <com.omitneedlesscode.droidconnyc.DebugTextView android:id="@+id/example_text_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="20dp" android:layout_marginLeft="20dp" android:text="@string/test_string" android:textSize=“28sp"/> </Layout> API 17+ API <17 One Layout -
1.Support RTL 2.Make font file a localized String 3.Mind font
padding 4.One layout to rule them all 5.Be careful with Spans Elliott’s Development Localization Checklist -
1.Support RTL 2.Make font file a localized String 3.Mind font
padding 4.One layout to rule them all 5.Be careful with Spans 6.Localize Line Heights Elliott’s Development Localization Checklist -
Line Height Add/Mult <resources> <item name="line_mult" format="float" type="integer">0.8</item> </resources> <resources>
<item name="line_mult" format="float" type=“integer">1.0</item> </resources> values/integers.xml values-th/integers.xml -
1.Support RTL 2.Make font file a localized String 3.Mind font
padding 4.One layout to rule them all 5.Be careful with Spans 6.Localize Line Heights 7.Pseudolocalizations Elliott’s Development Localization Checklist -
Pseudolocalization buildTypes { debug{ pseudoLocalesEnabled true } release { minifyEnabled
false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } -
Pseudolocalization buildTypes { debug{ pseudoLocalesEnabled true } release { minifyEnabled
false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }