我在android工程中,引入了flutter module工程,通过以下代码将flutter 的界面添加到android 界面中,发现flutter的界面摭在android 页面的上层,为什么看不到下层的呢。
flutter 页面代码如下:
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class DemoFlutterAndroid extends StatefulWidget {
var title;
DemoFlutterAndroid({Key? key, required this.title}) : super(key: key);
@override
State<DemoFlutterAndroid> createState() => _DemoFlutterAndroidState();
}
class _DemoFlutterAndroidState extends State<DemoFlutterAndroid> {
@override
Widget build(BuildContext context) {
print(rootBundle.toString());
return InkWell(
child: Container(
color: Colors.transparent,
child: Text("adsfas"),
),
onTap: (){
BotToast.showText(text: "dafsdfsdf");
},
);
}
}
android 添加flutter 代码如下:
FlutterFragment flutterFragment = FlutterFragment.withNewEngine().initialRoute(data).build();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.add(R.id.flutter_conent,flutterFragment);
transaction.commit();
android xml 布局如下:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--地图-->
<com.tencent.tencentmap.mapsdk.maps.MapView
android:id="@+id/map_content"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!--flutter页面占位-->
<FrameLayout
android:id="@+id/flutter_conent"
android:background="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
最终在android 页面中看不到底部的地图。
解锁Flutter开发新姿势,,系统掌握Flutter开发核心技术。
了解课程