我有一个应用程序最初是为Android 2.3设计的。现在我添加了一个带有ActionBarSherlock的ActionBar,并且一切都很好,除了在运行4.2的Nexus 7以外,它现在使用Holo主题的按钮和EditTexts。在我的主题从Theme.Light继承之前,现在它继承自Theme.Sherlock。我希望它甚至可以在较新的设备上使用旧的主题。我怀疑这是由值-V14夹下面一行造成的:强制使用ActionBarSherlock的应用程序使用主题而不是Theme.Holo
<style name="Sherlock.__Theme" parent="android:Theme.Holo">
所以我尝试删除该文件夹和V11文件夹只是为了看看它是否会解决这个问题,但随后的动作条走了完全。
然后我试图重写风格的EditText上是这样的:
<style name="AppTheme" parent="Theme.Sherlock">
<item name="@android:attr/editTextStyle">@android:style/Widget.EditText</item>
</style>
这应该让小部件不使用Widget.Holo主题,使用常规的主题,但没有奏效。
如何使Android 4.0+设备在使用ABS时使用原始主题而不是Holo主题?
下面我发布了一些代码,使用ABS一个示例应用程序当前呈现出河洛为主题的EditText,但应呈现有规律的EditText:
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>
styles.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是作为库项目添加的。
我面临同样的问题,你会详细说明你是如何修复它的。 –