當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。