本文整理汇总了Java中android.support.design.widget.Snackbar.SnackbarLayout方法的典型用法代码示例。如果您正苦于以下问题:Java Snackbar.SnackbarLayout方法的具体用法?Java Snackbar.SnackbarLayout怎么用?Java Snackbar.SnackbarLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.design.widget.Snackbar
的用法示例。
在下文中一共展示了Snackbar.SnackbarLayout方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateSnackbar
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
public void updateSnackbar(CoordinatorLayout parent, View dependency, View child) {
if (dependency instanceof Snackbar.SnackbarLayout) {
if (mSnackbarHeight == -1) {
mSnackbarHeight = dependency.getHeight();
}
int targetPadding = child.getMeasuredHeight();
int shadow = (int) ViewCompat.getElevation(child);
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) dependency.getLayoutParams();
layoutParams.bottomMargin = targetPadding - shadow;
child.bringToFront();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
child.getParent().requestLayout();
((View) child.getParent()).invalidate();
}
}
}
示例2: createRefreshSnackbar
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
/**
* 创建 正在刷新... - 上次刷新时间 Snackbar(用 SharedPreferences 保存上次刷新时间)
*
* @param view ViewGroup 子类
* @param str 记录上次刷新时间的标记:统一用TAG
*/
public void createRefreshSnackbar(ViewGroup view, String str) {
String currentDate = DateUtil.longDateToStrMDHMS(System.currentTimeMillis());
SharedPreferences spRefreshDate = getSharedPreferences(AppDelegate.SP_REFRESH_DATE, Context.MODE_PRIVATE);
String lastRefreshDate = spRefreshDate.getString(str, currentDate);
Snackbar snackbar = Snackbar.make(view, "正在刷新...", Snackbar.LENGTH_SHORT);
snackbar.setAction("上次刷新时间:" + lastRefreshDate, new View.OnClickListener() {
@Override
public void onClick(View v) {
// 这个点击事件必须加上不然 snackbar_action 就无法显示
// snackbar.dismiss();
}
});
TextView snackbar_action = (TextView) snackbar.getView().findViewById(R.id.snackbar_action);
snackbar_action.setTextSize(11f);
snackbar.setActionTextColor(getColors(R.color.white));
Snackbar.SnackbarLayout snackBarLayout = (Snackbar.SnackbarLayout) snackbar.getView();
snackBarLayout.setBackgroundColor(getColors(R.color.color_theme));
snackBarLayout.setAlpha(0.9f);
snackbar.show();
spRefreshDate.edit().putString(str, currentDate).commit();
}
示例3: onDependentViewRemoved
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
public void onDependentViewRemoved(
CoordinatorLayout parent,
FloatingTextButton child,
View dependency
) {
if (dependency instanceof Snackbar.SnackbarLayout) {
animation = ViewCompat.animate(child)
.translationY(0f)
.setInterpolator(HIDE_INTERPOLATOR)
.setDuration(HIDE_DURATION);
animation.start();
}
super.onDependentViewRemoved(parent, child, dependency);
}
示例4: addView
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
/**
* 添加SnackBar视图
* <p>在{@link #show()}之后调用</p>
*
* @param layoutId 布局文件
* @param params 布局参数
*/
public static void addView(@LayoutRes final int layoutId, @NonNull final ViewGroup.LayoutParams params) {
final View view = getView();
if (view != null) {
view.setPadding(0, 0, 0, 0);
Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) view;
View child = LayoutInflater.from(view.getContext()).inflate(layoutId, null);
layout.addView(child, -1, params);
}
}
示例5: layoutDependsOn
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
public boolean layoutDependsOn(CoordinatorLayout parent,
BriarRecyclerView child, View dependency) {
// we only want to trigger the change
// only when the changes is from a snackbar
return dependency instanceof Snackbar.SnackbarLayout;
}
示例6: addView
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
/**
* 添加snackbar视图
* <p>在{@link #show()}之后调用</p>
*
* @param layoutId 布局文件
* @param params 布局参数
*/
public static void addView(@LayoutRes final int layoutId, @NonNull final ViewGroup.LayoutParams params) {
final View view = getView();
if (view != null) {
view.setPadding(0, 0, 0, 0);
Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) view;
View child = LayoutInflater.from(view.getContext()).inflate(layoutId, null);
layout.addView(child, -1, params);
}
}
示例7: SnackbarAddView
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
/**
* 向Snackbar中添加view
* @param snackbar
* @param layoutId
* @param index 新加布局在Snackbar中的位置
*/
public static void SnackbarAddView(Snackbar snackbar, int layoutId, int index) {
View snackbarview = snackbar.getView();
Snackbar.SnackbarLayout snackbarLayout=(Snackbar.SnackbarLayout)snackbarview;
View add_view = LayoutInflater.from(snackbarview.getContext()).inflate(layoutId,null);
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
p.gravity= Gravity.CENTER_VERTICAL;
snackbarLayout.addView(add_view,index,p);
}
示例8: SnackbarAddView
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
/**
* 向Snackbar中添加view
* @param snackbar
* @param layoutId
* @param index 新加布局在Snackbar中的位置
*/
public static void SnackbarAddView( Snackbar snackbar,int layoutId,int index) {
View snackbarview = snackbar.getView();
Snackbar.SnackbarLayout snackbarLayout=(Snackbar.SnackbarLayout)snackbarview;
View add_view = LayoutInflater.from(snackbarview.getContext()).inflate(layoutId,null);
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT);
p.gravity= Gravity.CENTER_VERTICAL;
snackbarLayout.addView(add_view,index,p);
}
示例9: createLoadingSnackbar
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
/**
* 创建 正在加载... Snackbar
*
* @param view ViewGroup 子类
*/
public void createLoadingSnackbar(ViewGroup view) {
Snackbar snackbar = Snackbar.make(view, "正在加载...", Snackbar.LENGTH_INDEFINITE);
Snackbar.SnackbarLayout snackBarLayout = (Snackbar.SnackbarLayout) snackbar.getView();
snackBarLayout.setBackgroundColor(getColors(R.color.color_theme));
snackBarLayout.setAlpha(0.9f);
snackbar.show();
}
示例10: updateSnackbar
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
public void updateSnackbar(CoordinatorLayout parent, View dependency, View child) {
if (dependency instanceof Snackbar.SnackbarLayout) {
if (mSnackbarHeight == -1) {
mSnackbarHeight = dependency.getHeight();
}
int targetPadding = (mSnackbarHeight +
child.getMeasuredHeight());
dependency.setPadding(dependency.getPaddingLeft(),
dependency.getPaddingTop(), dependency.getPaddingRight(), targetPadding
);
}
}
示例11: layoutDependsOn
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
public boolean layoutDependsOn(
CoordinatorLayout parent,
FloatingTextButton child,
View dependency
) {
return dependency instanceof Snackbar.SnackbarLayout;
}
示例12: SnackbarAddView
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
/**
* 向Snackbar中添加view
*
* @param snackbar
* @param layoutId
* @param index 新加布局在Snackbar中的位置
*/
public static void SnackbarAddView(Snackbar snackbar, int layoutId, int index) {
View snackbarview = snackbar.getView();
Snackbar.SnackbarLayout snackbarLayout = (Snackbar.SnackbarLayout) snackbarview;
View add_view = LayoutInflater.from(snackbarview.getContext()).inflate(layoutId, null);
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
p.gravity = Gravity.CENTER_VERTICAL;
snackbarLayout.addView(add_view, index, p);
}
示例13: SnackbarAddView
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
/**
* 向Snackbar中添加view
* @param snackbar
* @param layoutId
* @param index 新加布局在Snackbar中的位置
*/
public static void SnackbarAddView( Snackbar snackbar,int layoutId,int index) {
View snackbarview = snackbar.getView();
Snackbar.SnackbarLayout snackbarLayout=(Snackbar.SnackbarLayout)snackbarview;
View add_view = LayoutInflater.from(snackbarview.getContext()).inflate(layoutId,null);
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
p.gravity= Gravity.CENTER_VERTICAL;
snackbarLayout.addView(add_view,index,p);
}
示例14: isDependent
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
private boolean isDependent(View dependency) {
return dependency instanceof BottomNavigationBar || dependency instanceof Snackbar.SnackbarLayout;
}
示例15: layoutDependsOn
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, V child, View dependency) {
mWithSnackBarImpl.updateSnackbar(parent, dependency, child);
return dependency instanceof Snackbar.SnackbarLayout;
}