第一步:xxx/res/values/styles.xml中加入自定义Activity的Theme,如下所示:
<style name="Transparent" parent="android:Theme.Light"><!--将Activity的Theme设置成透明--><item name="android:windowIsTranslucent">true</item></style>
<activityandroid:name=".activities.GoodsListActivity"android:screenOrientation="portrait"android:theme="@style/Transparent"/>
再报这个错之前应该会报另一个错误。
运行发现汇报错误:
You need to use a Theme.AppCompat theme (or descendant) with this activity.
你需要使用Theme.AppCompat theme
只需修改一下style
<style name="Transparent" parent="Theme.AppCompat.Light.NoActionBar"><!--将Activity的Theme设置成透明--><item name="android:windowIsTranslucent">true</item></style>ok了;