当我从Android应用程序的调试版本转移到发行版本时,ActionBar中的后退导航箭头被汉堡包取代了(因为我想起个更好的名字),
>这是调试版本,带有应有的向后箭头。
这是发布版本以及汉堡包。
这是默认的后退箭头,当用户使用Jetpack导航组件在AppBarLayout中导航到片段时,该默认后退箭头如下所示:
Widget build(BuildContext context) {
if (!loaded) _loadZones();
return new Scaffold(
body: new Column(
children: <Widget>[
new Padding(padding: EdgeInsets.fromLTRB(0, 20, 0, 0)),
new Expanded(
child: new ListView.builder(
shrinkWrap: true, //Added
itemCount: zones.length,
itemBuilder: (BuildContext context, int index) {
Zone zone = zones[index];
List<Place> places = zone.places;
print(zone.toString());
print(places.length);
return InkWell(
onTap: () {
Navigator.push(
context,
FromRightToLeft(
builder: (context) => CondominiumScreen(zone.id)),
);
},
child: Card(
color: Colors.white,
key: Key(zone.name),
margin: EdgeInsets.fromLTRB(10, 5, 10, 5),
child: new InkWell(
child: new Column(
children: <Widget>[
ListTile(
leading: Icon(Icons.place),
title: Row(
children: <Widget>[
Icon(
Icons.place,
color: Colors.grey,
),
Text(
' ${zone.name}',
style: TextStyle(fontSize: 20),
),
],
)),
new Divider(),
new ListView.builder( //removed Flexible
shrinkWrap: true, //Added
itemCount: places.length,
itemBuilder: (BuildContext ct, int i) {
Place place = places[i];
return Text(
"● ${place.name}",
textAlign: TextAlign.start,
);
}),
new Divider(),
new Row(
children: <Widget>[
Padding(
padding: EdgeInsets.fromLTRB(5, 0, 5, 0),
),
Expanded(
flex: 50,
child: InkWell(
child: FlatButton(
child: const Text('Reportes'),
shape: RoundedRectangleBorder(
side: BorderSide(
color: Colors.black12)),
splashColor: Colors.white10,
color: Colors.white,
onPressed: () {
/* ... */
})),
),
Padding(
padding: EdgeInsets.fromLTRB(5, 0, 5, 0)),
Expanded(
flex: 50,
child: InkWell(
child: FlatButton(
child: const Text('Turnos'),
shape: RoundedRectangleBorder(
side: BorderSide(
color: Colors.black12)),
splashColor: Colors.white10,
color: Colors.white,
onPressed: () {
/* ... */
})),
),
Padding(
padding: EdgeInsets.fromLTRB(5, 0, 5, 0),
),
],
),
],
))));
}))
],
));
}
当我在发行版中关闭缩小功能时,会再次显示后退箭头。所以这与缩小有关。
但是我要告诉ProGuard保留什么?我尝试了所有这些方法,但都无济于事:
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay">
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
谢谢!
答案 0 :(得分:2)
使用时:
您会遇到此问题,因为proguard规则仍引用了支持库版本。
它在导航2.2.1和更高版本中已修复(请参见https://issuetracker.google.com/issues/147610424)
答案 1 :(得分:1)
我遇到了同样的问题,并在Google Issue Tracker中发现了它。有人在那里找到了解决方案:
-keep class androidx.appcompat.graphics.drawable.DrawerArrowDrawable { *; }
显然,默认情况下,Proguard对后退箭头可绘制对象(DrawerArrowDrawable)进行了模糊处理。这为我解决了问题,而且您没有其他任何Proguard规则。
您还应该将android.support.v4.app.Fragment
替换为androidx.fragment.app.Fragment
(尽管它与您的问题无关)