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


Java LinearLayout.requestLayout方法代码示例

本文整理汇总了Java中android.widget.LinearLayout.requestLayout方法的典型用法代码示例。如果您正苦于以下问题:Java LinearLayout.requestLayout方法的具体用法?Java LinearLayout.requestLayout怎么用?Java LinearLayout.requestLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.LinearLayout的用法示例。


在下文中一共展示了LinearLayout.requestLayout方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showCenterToast

import android.widget.LinearLayout; //导入方法依赖的package包/类
public static void showCenterToast(Context context, String title, @DrawableRes int drawableId, int duration) {
    Toast toast = makeText(context.getApplicationContext(), title, duration);
    toast.setGravity(Gravity.CENTER, 0, 0);
    View view = LayoutInflater.from(context).inflate(R.layout.layout_center_toast, null);
    LinearLayout rlContent = (LinearLayout) view.findViewById(R.id.rl_content);
    TextView content = (TextView) view.findViewById(R.id.tv_content);
    ImageView alertIcon = (ImageView) view.findViewById(R.id.iv_icon);
    if (drawableId != 0) {
        alertIcon.setVisibility(View.VISIBLE);
        alertIcon.setImageResource(drawableId);
    } else {
        alertIcon.setVisibility(View.GONE);
    }
    if (!TextUtils.isEmpty(title)) {
        content.setText(title);
    }
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    int screenWidth = wm.getDefaultDisplay().getWidth();
    int width = (int) (screenWidth / 2f);
    FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) rlContent.getLayoutParams();
    lp.width = width;
    rlContent.setLayoutParams(lp);
    rlContent.requestLayout();
    toast.setView(view);
    toast.show();
}
 
开发者ID:Jusenr,项目名称:androidtools,代码行数:27,代码来源:ToastUtils.java

示例2: showAlertToast

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 * Show alert toast view
 *
 * @param context    context
 * @param title      title
 * @param drawableId drawable Id
 * @param duration   duration
 */
public static void showAlertToast(Context context, String title, @DrawableRes int drawableId, int duration) {
    Toast toast = makeText(context.getApplicationContext(), title, duration);
    toast.setGravity(Gravity.CENTER, 0, 0);//the setting position of
    View view = LayoutInflater.from(context).inflate(R.layout.layout_alert_toast, null);
    LinearLayout llContent = (LinearLayout) view.findViewById(R.id.ll_content);
    ImageView alertIcon = (ImageView) view.findViewById(R.id.iv_alert_icon);
    TextView alertTitle = (TextView) view.findViewById(R.id.tv_alert_title);
    if (drawableId != 0) {
        alertIcon.setVisibility(View.VISIBLE);
        alertIcon.setImageResource(drawableId);
    } else {
        alertIcon.setVisibility(View.GONE);
    }
    if (!TextUtils.isEmpty(title)) {
        alertTitle.setText(title);
    }
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    int screenWidth = wm.getDefaultDisplay().getWidth();
    int width = (int) (screenWidth / 1.5f);
    CardView.LayoutParams lp = (CardView.LayoutParams) llContent.getLayoutParams();
    lp.width = width;
    llContent.setLayoutParams(lp);
    llContent.requestLayout();
    toast.setView(view);//Set appearance
    toast.show();
}
 
开发者ID:Jusenr,项目名称:androidtools,代码行数:35,代码来源:ToastUtils.java

示例3: bindCardSubviews

import android.widget.LinearLayout; //导入方法依赖的package包/类
private void bindCardSubviews() {
    cfDialogScrollView = (ScrollView) dialogCardView.findViewById(R.id.cfdialog_scrollview);
    cfDialogBodyContainer = (LinearLayout) dialogCardView.findViewById(R.id.alert_body_container);
    cfDialogHeaderLinearLayout = (LinearLayout) dialogCardView.findViewById(R.id.alert_header_container);
    cfDialogHeaderLinearLayout.requestLayout();
    cfDialogHeaderLinearLayout.setVisibility(View.GONE);
    dialogTitleTextView = (TextView) dialogCardView.findViewById(R.id.tv_dialog_title);
    iconTitleContainer = (LinearLayout) dialogCardView.findViewById(R.id.icon_title_container);
    cfDialogIconImageView = (ImageView) dialogCardView.findViewById(R.id.cfdialog_icon_imageview);
    dialogMessageTextView = (TextView) dialogCardView.findViewById(R.id.tv_dialog_content_desc);
    buttonContainerLinearLayout = (LinearLayout) dialogCardView.findViewById(R.id.alert_buttons_container);
    cfDialogFooterLinearLayout = (LinearLayout) dialogCardView.findViewById(R.id.alert_footer_container);
    selectableItemsContainer = (LinearLayout) dialogCardView.findViewById(R.id.alert_selection_items_container);
}
 
开发者ID:Codigami,项目名称:CFAlertDialog,代码行数:15,代码来源:CFAlertDialog.java


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