Android アプリにフォント ピッカーを実装しようとしています。素敵なカラー ピッカーをいくつか見つけました。アプリにポップできるフォント ピッカーの例を教えてもらえますか?
2 に答える
これは有望に見えます:
Androidプラットフォームでのフォントの列挙
http://www.ulduzsoft.com/2012/01/enumerating-the-fonts-on-android-platform/
Android用のFontPreferenceダイアログ
http://www.ulduzsoft.com/2012/01/fontpreference-dialog-for-android/
ListView を使用して作成するのは非常に簡単です。リスト内の各行は、テキストがフォントの名前に設定され、使用される書体が実際のフォントである TextView である可能性があります。
リストビューについて特別なことは何もする必要はありません。ArrayAdapter を使用した単純なリストビューで十分です。このようなアダプタを使用するとうまくいくはずです。
このコードは、問題を解決するために何をする必要があるかを説明するためではなく、コンパイルするためのものではないことに注意してください。ただし、始めるには十分なはずです。
public class FontListAdapter extends ArrayAdapter< String >
{
public FontListAdapter(Activity context, String[] title, boolean[] isHeader) {
super(context, R.layout.listitem, title);
this.context = context;
this.isHeader = isHeader;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
TextView t;
if (convertView==null)
t = new TextView(parent.getContext());
else
t = (TextView) convertView;
t.setText(getFontName());
t.setTypeface(getFont());
return convertView;
}
public Typeface getFont(int pos){
TypeFace tf = getTypeFaceForThisPosition(pos); // you need to figure this out
return tf;
}
public String getFontName(int pos){
String fontName = getFontNameForThisPosition(pos); // you need to figure this out
return FontName;
}
}
また、これを見ることができます: http://www.netmite.com/android/mydroid/1.0/development/apps/FontLab/src/com/android/fontlab/FontPicker.java