我有一个包含 3 个项目的底部导航视图。我只想为每个选项卡提供居中文本,因此希望完全删除图标(不仅使它们透明)。
如何删除图标并使标题居中?
我的代码:(更喜欢 XML 中的解决方案)
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_alignParentBottom="true">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/navigationBar"
android:background="@color/navigation"
app:theme="@style/BottomNavigationTheme"
app:menu="@menu/bottom_navigation_menu"
android:minHeight="@dimen/abc_action_bar_default_height_material">
</com.google.android.material.bottomnavigation.BottomNavigationView>
</RelativeLayout>
</merge>
Run Code Online (Sandbox Code Playgroud)
底部导航菜单.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/ic_home"
android:title="@string/home">
</item>
<item
android:id="@+id/ic_today"
android:title="@string/today">
</item>
<item
android:id="@+id/ic_you"
android:title="@string/you">
</item>
</menu>
Run Code Online (Sandbox Code Playgroud) 我有一个两步登录表单,用户首先输入电子邮件,然后进入下一页,在其中输入密码。在将用户带到密码页面之前,我想检查用户输入的电子邮件是否有效以及它是否存在于 firebase 中。我读过一些关于使用fetchSignInMethodsForEmail. 但是,我不太确定如何实现这一点。
这个想法是,如果电子邮件确实存在,则用户将被带到密码页面,但是,如果电子邮件不存在,则会弹出一个带有按钮的小吃栏,将用户带到注册页面。我该怎么做呢?
这就是我到目前为止所拥有的......
FirebaseAuth auth = FirebaseAuth.instance;
final nextButton = Container(
margin: const EdgeInsets.only(
top: 30.0,
),
child: FloatingActionButton(
onPressed: () async {
try {
List<String> userSignInMethods = await auth.fetchSignInMethodsForEmail(email)(
email: _emailController.text,
);
if (userSignInMethods != null) {
final page = LoginPassword();
Navigator.of(context).push(CustomPageRoute(page));
}
} catch (e) {
print(e);
//TODO: Snackbar
}
},
tooltip: 'Next',
backgroundColor: AppTheme.define().primaryColor,
child: Icon(
AppIcons.next_button,
size: 20.0,
),
),
);Run Code Online (Sandbox Code Playgroud)
未fetchSignInMethodsForEmail正确实施,我收到错误。
我正在制作一个简单的密码重置对话框,它将通过 firebase 向用户发送密码重置电子邮件。一切工作正常,但是,我希望能够相应地捕获和处理错误。我似乎不知道如何去做这件事。例如,当用户的互联网连接中断时,我希望他们看到一条消息,表明他们的密码重置电子邮件不是通过小吃栏发送的。
我的代码:
// Send user an email for password reset
Future<void> _resetPassword(String email) async {
await auth.sendPasswordResetEmail(email: email);
}
// This will handle the password reset dialog for login_password
void passwordResetDialog(context, email) {
displayDialog(
context,
title: "Forgot Password?",
content:
"We will send you an email with a password reset link. Press on that link and follow the instructions from there.",
leftOption: "No",
onPressedLeftOption: () {
// Close dialog
Navigator.of(context).pop();
},
rightOption: "Yes",
onPressedRightOption: () {
// Send reset …Run Code Online (Sandbox Code Playgroud) 我有一个水平RecyclerView显示来自用户设备的 7 张图像(随着用户不断拍照而变化)。我想在 7 个图像的末尾添加一个默认图标,具有 onclick 功能。我该怎么做呢?
在上图中,加号图标应该是默认图标,但它应该位于图像的末尾。
更新:
最近的照片适配器.java
public class RecentPhotosAdapter extends RecyclerView.Adapter<RecentPhotosAdapter.ViewHolder> {
// Variables
private Context mContext;
private ArrayList<String> mImage;
private int VIEW_TYPE_DEFAULT = 0;
private int VIEW_TYPE_IMAGE = 1;
// Limit the recent photo selection
int RECENT_PHOTO_LIMIT = 7;
public RecentPhotosAdapter(Context mContext, ArrayList<String> mImage) {
this.mContext = mContext;
this.mImage = mImage;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (viewType == VIEW_TYPE_IMAGE) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recent_photos_item, parent, …Run Code Online (Sandbox Code Playgroud)我创建了一个简单的播放图标。我将 SVG 文件导入 Android Studio 并将其作为 imageView 来源。然而,不幸的是我无法从我的 Adope XD 文档中引入下拉阴影。在这两种情况下,我一直在尝试通过代码复制下拉阴影效果。然而我一直没有成功。
我一直在搞乱现有的代码,但没有成功。这是我到目前为止所拥有的:
图片查看:
<ImageView
android:id="@+id/thumbnail_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@drawable/background_drop_shadow"
app:srcCompat="@drawable/ic_next_button_image_select" />Run Code Online (Sandbox Code Playgroud)
ic_next_button_image_select(导入的 SVG):
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40dp"
android:height="38dp"
android:viewportWidth="40"
android:viewportHeight="38">
<path
android:pathData="M12,0L28,0A12,12 0,0 1,40 12L40,26A12,12 0,0 1,28 38L12,38A12,12 0,0 1,0 26L0,12A12,12 0,0 1,12 0z"
android:fillColor="#1ed760"/>
<path
android:pathData="M27.6,17.28a2,2 0,0 1,-0 3.439l-10.083,5.987A2,2 0,0 1,14.5 24.987L14.5,13.013a2,2 0,0 1,3.021 -1.72Z"
android:fillColor="#090909"/>
</vector>Run Code Online (Sandbox Code Playgroud)
background_drop_shadow(我找到并尝试使用的代码):
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Drop Shadow Stack -->
<item>
<shape>
<padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" />
<stroke android:color="#02000000" android:width="1dp" …Run Code Online (Sandbox Code Playgroud)