もともと Android 2.3 用にスタイル設定されたアプリがあります。現在、ActionBarSherlock を使用して ActionBar を追加しています。4.2 を実行している Nexus 7 を除いて、すべて問題ありません。ボタンと EditText に Holo テーマを使用しています。私のテーマは Theme.Light から継承していましたが、現在は Theme.Sherlock から継承しています。新しいデバイスでも古いテーマを使用したい. これは、values-v14 フォルダー内の次の行が原因であると思われます。
<style name="Sherlock.__Theme" parent="android:Theme.Holo">
そのため、問題が解決するかどうかを確認するために、そのフォルダーと v11 フォルダーを削除しようとしましたが、ActionBar は完全になくなりました。
次に、次のように EditText のスタイルをオーバーライドしてみました。
<style name="AppTheme" parent="Theme.Sherlock">
<item name="@android:attr/editTextStyle">@android:style/Widget.EditText</item>
</style>
これにより、ウィジェットは Widget.Holo テーマを使用せず、通常のテーマを使用するようになるはずでしたが、うまくいきませんでした。
ABS を使用しているときに Android 4.0 以降のデバイスで Holo テーマの代わりに元のテーマを使用するにはどうすればよいですか?
以下に、現在 Holo をテーマにした EditText を表示しているが、通常の EditText を表示する必要がある ABS を使用するサンプル アプリケーションのコードをいくつか投稿しました。
MainActivity.java:
import android.os.Bundle;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
public class MainActivity extends SherlockActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getSupportMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />
<EditText
android:layout_height="match_parent"
android:layout_width="match_parent"/>
</RelativeLayout>
スタイル.xml:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppTheme" parent="Theme.Sherlock">
<item name="@android:attr/editTextStyle">@android:style/Widget.EditText</item>
</style>
</resources>
また、マニフェストのテーマは AppTheme で、ライブラリ プロジェクトとして ABS が追加されています。