关于flutter module 的引用问题
来源:15-1 自测小作业(带着9个问题去学习)
qq_偽妳牵掛_luyR23
2022-10-27
我在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 页面中看不到底部的地图。
写回答
2回答
-
CrazyCodeBoy
2022-10-30
透传事件还不支持,可以将xml的framelayout改成LinearLayout然后,给地图和flutter布局分别设置下高度看看。00 -
CrazyCodeBoy
2022-10-28
布局设置的问题,你在xml中修改下flutter页面的宽高试试看012022-10-28
相似问题