您的位置:首页 > 移动开发

java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the

2017-03-07 15:24 1311 查看
java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library

我遇到这个错误是在fragment里应用了coordinatorLayout,xml inflate无效

查了好多这是最新的sdk的bug

解决办法:在style里写一个自定义的style,然后在加入这个fragment的Activty 添加theme

<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<activity
android:name="EventsDetailsActivity"
android:theme="@style/AppTheme.NoActio>


还有一种方法就是直接给fragment添加theme,在代码里直接添加

final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.community_theme);
// clone the inflater using the ContextThemeWrapper
LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);
View viewRoot = localInflater.inflate(R.layout.fragment_rank_landing, container, false);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  bug
相关文章推荐