解决混合开发黑屏问题
- 将Android项目中嵌入Flutter工程的时候,在跳转的时候会黑屏,目前我也没有找到很好的方法,网上的方法也试了一下,目前也还没有比较好的效果,有道友留言说打release 也许不会黑屏这个我没试验,有兴趣的道友可以试试,下面来说说这种简单粗暴的方法这是在debug模式下操作的:
- 直接配置当前activity的theme为透明
<style name="FlutterTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@drawable/task_bg</item>
</style>
复制代码
<activity
android:name="com.readnewhome.FlutterIntegralCenterActivity"
android:screenOrientation="portrait"
android:theme="@style/FlutterTheme" >
</activity>
复制代码
- 其次是设置flutter页面android状态栏全透明
- 这是一种比较简单的方法直接看代码吧
public class MainActivity extends FlutterActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
{
// api大于21设置状态栏透明
getWindow().setStatusBarColor(0);
}
GeneratedPluginRegistrant.registerWith(this);
}
}
复制代码