當使用基於xml的佈局使用AppCompat 22.1.0時,並非所有支持的小部件都使用Android 4.4爲我的碎片着色或材質化。AppCompat v22.1.0不會將所有的xml小部件正確地轉換爲片段
我看到此行爲具有以下部件(其他未測試):
- 單選按鈕(無色彩的顏色)
- 複選框(無色彩的顏色)
- 微調(設備默認的主題應用)
- 的EditText(設備默認的主題應用)
- 的RatingBar(設備默認的主題應用)
- 按鈕(設備defaul t主題)
它曾經在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>
用22.1.1固定 –
確實! Google快速回復! –