在Oreo下,我的Theming停止工作(适用于较低级别的API)并且没有被选中。我有以下内容:
report_layout.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/company_list_header"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?companyTextTitle">
attrs.xml
<attr name="companyTextTitle" format="reference"/>
的themes.xml
<style name="Theme.Black" parent="Theme">
<item name="companyTextTitle">@style/company_text_title</item>
</style>
<style name="Theme" parent="android:Theme">
<item name="android:listViewStyle">@style/list</item>
<item name="android:absListViewStyle">@style/list</item>
<item name="android:editTextStyle">@style/edittext</item>
<item name="android:buttonStyle">@style/stdbutton</item>
<item name="android:spinnerStyle">@style/spinner</item>
<item name="android:spinnerItemStyle">@style/spinneritem</item>
<item name="android:checkboxStyle">@style/checkbox</item>
<item name="android:radioButtonStyle">@style/radio</item>
<item name="android:preferenceStyle">@style/preference</item>
<item name="android:listChoiceIndicatorSingle">@drawable/btn_radio</item>
<item name="android:spinnerDropDownItemStyle">@style/spinnerradio</item>
<item name="android:buttonBarButtonStyle">@style/stdbutton</item>
</style>
styles.xml:
<style name="company_text_title">
<item name="android:textColor">#000000</item>
<item name="android:textStyle">bold</item>
<item name="android:gravity">center_vertical|left</item>
<item name="android:paddingLeft">2sp</item>
<item name="android:paddingRight">2sp</item>
<item name="android:background">#004488</item>
</style>
在我的活动中:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.report_layout);
setTheme(R.style.Theme_Black);
清单:
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="false"
android:anyDensity="true"/>
<activity android:name=".ReportList" android:label="@string/app">
<intent-filter>
<action android:name="com.xyz.app.REPORTLIST"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
的build.gradle
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
minSdkVersion 14
targetSdkVersion 14
}
不喜欢:
style="?companyTextTitle">
但这有效:
style="@style/company_text_title">
有人见过这个吗?
答案 0 :(得分:0)
发现问题,必须设置:
setTheme(R.style.Theme_Black);
之前:
setContentView(R.layout.report_list);
即
setTheme(R.style.Theme_Black);
setContentView(R.layout.report_layout);
在奥利奥之前说过它以前也是如此...