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