当前位置: 首页>>代码示例>>Java>>正文


Java Snackbar.SnackbarLayout方法代码示例

本文整理汇总了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();
        }

    }
}
 
开发者ID:homeii,项目名称:GxIconDIY,代码行数:21,代码来源:BottomNavigationBehavior.java

示例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();
}
 
开发者ID:jpaijh,项目名称:TYT,代码行数:28,代码来源:BaseActivity.java

示例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);
}
 
开发者ID:dimorinny,项目名称:floating-text-button,代码行数:18,代码来源:SnackbarBehavior.java

示例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);
    }
}
 
开发者ID:AriesHoo,项目名称:FastLib,代码行数:17,代码来源:SnackBarUtil.java

示例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;
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:8,代码来源:BriarRecyclerViewBehavior.java

示例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);
    }
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:17,代码来源:SnackbarUtils.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:SnackbarUtil.java

示例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);
}
 
开发者ID:BobbyZhang93,项目名称:BestBlog,代码行数:18,代码来源:SnackbarUtil.java

示例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();
}
 
开发者ID:jpaijh,项目名称:TYT,代码行数:13,代码来源:BaseFragment.java

示例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
        );
    }
}
 
开发者ID:homeii,项目名称:GxIconAndroid,代码行数:14,代码来源:BottomNavigationBehavior.java

示例11: layoutDependsOn

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
public boolean layoutDependsOn(
        CoordinatorLayout parent,
        FloatingTextButton child,
        View dependency
) {
    return dependency instanceof Snackbar.SnackbarLayout;
}
 
开发者ID:dimorinny,项目名称:floating-text-button,代码行数:9,代码来源:SnackbarBehavior.java

示例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);
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:21,代码来源:SnackbarUtil.java

示例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);
}
 
开发者ID:orchidTJJ,项目名称:getword,代码行数:18,代码来源:SnackbarUtil.java

示例14: isDependent

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
private boolean isDependent(View dependency) {
    return dependency instanceof BottomNavigationBar || dependency instanceof Snackbar.SnackbarLayout;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:BottomNavBarFabBehaviour.java

示例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;
}
 
开发者ID:by-syk,项目名称:NanoIconPack,代码行数:6,代码来源:BottomNavigationBehavior.java


注:本文中的android.support.design.widget.Snackbar.SnackbarLayout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。