gpt4 book ai didi

android - 如何在选项卡中制作 Snackbar Match_Parent?

转载 作者:行者123 更新时间:2023-11-29 19:46:47 28 4
gpt4 key购买 nike

我正在尝试在 TAB 中将 Snakbar 设为 MatchParent。我所做的是:

Snackbar snackbar = Snackbar
.make(coordinatorLayout, mMessage, Snackbar.LENGTH_LONG);

View view = snackbar.getView();
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
params.width = CoordinatorLayout.LayoutParams.MATCH_PARENT;
params.gravity = Gravity.CENTER | Gravity.BOTTOM;
view.setLayoutParams(params);

snackbar.show();

不给MatchParent增加宽度有点大

最佳答案

对于仍在寻找答案的任何人:

Snackbar snackbar = Snackbar
.make(coordinatorLayout, mMessage, Snackbar.LENGTH_LONG);

View view = snackbar.getView();
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) view.getLayoutParams();+
params.gravity = Gravity.FILL_HORIZONTAL | Gravity.BOTTOM;
view.setLayoutParams(params);

snackbar.show();

“FILL_HORIZONTAL”帮了我的忙。

关于android - 如何在选项卡中制作 Snackbar Match_Parent?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37462703/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com