【发布时间】:2015-06-30 15:05:57
【问题描述】:
当使用 AppCompat 22.1.0 使用基于 xml 的布局时,并非所有受支持的小部件都为我使用 Android 4.4 的片段着色或以材料为主题。
我看到以下小部件的这种行为(其他小部件未测试):
- 单选按钮(无色调)
- 复选框(无色调)
- 微调器(应用设备默认主题)
- EditText(应用设备默认主题)
- RatingBar(应用设备默认主题)
- 按钮(应用设备默认主题)
它曾经在 AppCompat v22.0.0 中工作。
屏幕截图(左 4.4,右 5.0):
MainActivity.java:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
}
}
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
return rootView;
}
}
}
fragment_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="RadioButton test"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="CheckBox test"/>
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/someStrings"/>
</LinearLayout>
Themes.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"></style>
</resources>
【问题讨论】:
-
确实!来自 Google 的快速响应!
标签: android android-fragments material-design android-appcompat