11
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

appcompat 21+でPreferenceActivityを実現する方法

Last updated at Posted at 2015-04-02

appcompat-22ならもっと簡単に実現できます。
appcompat 22でPreferenceActivityを実現する方法


appcompat-21以降ではActionBarActivityを継承したActivityがMaterialテーマになりますが、いわゆる設定画面を実現するPreferenceActivityはActionBarActivityを継承していないために実にかっこ悪い設定画面になります。

PreferenceActivity ActionBarActivity+PreferenceFragment
appcompat-v21対応(対応前).png appcompat-v21対応(対応後).png

そこで PreferenceActivity の代わりに ActionBarActivity+PreferenceFragment を使うのが定石です。Jake神もそう言ってます。

AppCompat v21 — Lollipop 搭載前のデバイスにマテリアル デザインを! - Google Developer Japan Blog

''Preferences で AppCompat を使用するにはどうしたらいいですか? ''
API v11 以上のデバイスでは、引き続き ActionBarActivity で PreferenceFragment を使用できます。それより古いデバイスではマテリアル スタイル化されていない、通常の PreferenceActivity を提供する必要があります。

Android2.x対応のためには?

PreferenceFragment は Android 2.x 非対応なので PreferenceFragment-Compat を利用するといいです。

RingtonePreference は動作しない場合があるので Not work with RingtonePreference · Issue #1 · kolavar/android-support-v4-preferencefragment を参考に修正してください。

11
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?