下面列出了android.widget.FrameLayout#setOnClickListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@NonNull
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
FrameLayout layout = new FrameLayout(requireSceneContext());
layout.setBackgroundColor(Color.parseColor("#99000000"));
TextView textView = new TextView(getActivity());
textView.setText(getNavigationScene().getStackHistory());
textView.setBackgroundColor(ColorUtil.getMaterialColor(getResources(), 1));
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(600, 600);
layoutParams.gravity = Gravity.CENTER;
layout.addView(textView, layoutParams);
layout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
requireNavigationScene().pop();
}
});
return layout;
}
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.fragment_chatmessage_list, container, false);
mRecyclerView = (RecyclerView) mView.findViewById(R.id.chat_message_list);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
linearLayoutManager.setReverseLayout(true);
mRecyclerView.setLayoutManager(linearLayoutManager);
messageRecyclerAdapter = new ChatMessageRecyclerAdapter(getActivity(), this);
mRecyclerView.setAdapter(messageRecyclerAdapter);
compose = (EditText) mView.findViewById(R.id.chat_compose);
sendBox = (FrameLayout) mView.findViewById(R.id.chat_send_box);
sendBox.setOnClickListener(onClickSend);
refreshChatMessages();
EventBus.getDefault().register(this);
return mView;
}
public void addStickerTab(TLRPC.Document sticker) {
final int position = tabCount++;
FrameLayout tab = new FrameLayout(getContext());
tab.setTag(sticker);
tab.setFocusable(true);
tab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
delegate.onPageSelected(position);
}
});
tabsContainer.addView(tab);
tab.setSelected(position == currentPosition);
BackupImageView imageView = new BackupImageView(getContext());
imageView.setAspectFit(true);
tab.addView(imageView, LayoutHelper.createFrame(30, 30, Gravity.CENTER));
}
public ActionBarLayer(Context context, ActionBar actionBar) {
super(context);
parentActionBar = actionBar;
backButtonFrameLayout = new FrameLayout(context);
addView(backButtonFrameLayout);
LayoutParams layoutParams = (LayoutParams) backButtonFrameLayout.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.FILL_PARENT;
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
backButtonFrameLayout.setLayoutParams(layoutParams);
backButtonFrameLayout.setPadding(0, 0, OSUtilities.dp(4), 0);
backButtonFrameLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (isSearchFieldVisible) {
closeSearchField();
return;
}
if (actionBarMenuOnItemClick != null) {
actionBarMenuOnItemClick.onItemClick(-1);
}
}
});
backButtonFrameLayout.setEnabled(false);
}
@VisibleForTesting
boolean drawDashboardButton(Context context,
LinearLayout layout,
FrameLayout dashboardButton,
int accentColor) {
boolean dashboardEnabled = U.getBooleanPrefWithDefault(context, PREF_DASHBOARD);
if(dashboardEnabled) {
layout.findViewById(R.id.square1).setBackgroundColor(accentColor);
layout.findViewById(R.id.square2).setBackgroundColor(accentColor);
layout.findViewById(R.id.square3).setBackgroundColor(accentColor);
layout.findViewById(R.id.square4).setBackgroundColor(accentColor);
layout.findViewById(R.id.square5).setBackgroundColor(accentColor);
layout.findViewById(R.id.square6).setBackgroundColor(accentColor);
dashboardButton.setOnClickListener(v -> U.sendBroadcast(context, ACTION_TOGGLE_DASHBOARD));
dashboardButton.setVisibility(View.VISIBLE);
} else
dashboardButton.setVisibility(View.GONE);
return dashboardEnabled;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cart_popupview);
linearLayout = (LinearLayout) findViewById(R.id.linearlayout);
clearLayout = (LinearLayout)findViewById(R.id.clear_layout);
shopingcartLayout = (FrameLayout)findViewById(R.id.shopping_cart_layout);
bottomLayout = (LinearLayout)findViewById(R.id.shopping_cart_bottom);
totalPriceTextView = (TextView)findViewById(R.id.shopping_cart_total_tv);
totalPriceNumTextView = (TextView)findViewById(R.id.shopping_cart_total_num);
recyclerView = (RecyclerView)findViewById(R.id.recycleview);
shopingcartLayout.setOnClickListener(this);
bottomLayout.setOnClickListener(this);
clearLayout.setOnClickListener(this);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
dishAdapter = new AdapterPopupDish(getContext(), mModelShopCart);
recyclerView.setAdapter(dishAdapter);
dishAdapter.setShopCartInterface(this);
showTotalPrice();
}
private View getColorItemView(final Context context, int position, boolean isSelect) {
int color = mColors[position];
int widthImageCheckView = Utils.convertDensityPix(context, 24);
int widthColorView = Utils.convertDensityPix(context, 56);
int widthMargin = Utils.convertDensityPix(context, 4);
ImageView imageView = new ImageView(context);
imageView.setImageResource(R.drawable.ic_done_white_24dp);
FrameLayout.LayoutParams ivParams = new FrameLayout.LayoutParams(widthImageCheckView, widthImageCheckView);
ivParams.gravity = Gravity.CENTER;
imageView.setLayoutParams(ivParams);
imageView.setVisibility(isSelect ? View.VISIBLE : View.INVISIBLE);
FrameLayout frameLayout = new FrameLayout(context);
GridLayout.LayoutParams params = new GridLayout.LayoutParams(new FrameLayout.LayoutParams(widthColorView, widthColorView));
params.setGravity(Gravity.CENTER);
params.setMargins(widthMargin, widthMargin, widthMargin, widthMargin);
frameLayout.setLayoutParams(params);
setBackgroundSelector(frameLayout, color);
frameLayout.addView(imageView);
frameLayout.setOnClickListener(this);
frameLayout.setTag(position);
return frameLayout;
}
public void addStickerTab(TLRPC.Chat chat) {
final int position = tabCount++;
FrameLayout tab = new FrameLayout(getContext());
tab.setFocusable(true);
tab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
delegate.onPageSelected(position);
}
});
tabsContainer.addView(tab);
tab.setSelected(position == currentPosition);
BackupImageView imageView = new BackupImageView(getContext());
imageView.setRoundRadius(AndroidUtilities.dp(15));
TLRPC.FileLocation photo = null;
AvatarDrawable avatarDrawable = new AvatarDrawable();
if (chat.photo != null) {
photo = chat.photo.photo_small;
}
avatarDrawable.setTextSize(AndroidUtilities.dp(14));
avatarDrawable.setInfo(chat);
imageView.setImage(photo, "50_50", avatarDrawable);
imageView.setAspectFit(true);
tab.addView(imageView, LayoutHelper.createFrame(30, 30, Gravity.CENTER));
}
private void populateWallpapersFromAdapter(ViewGroup parent, BaseAdapter adapter,
boolean addLongPressHandler) {
for (int i = 0; i < adapter.getCount(); i++) {
FrameLayout thumbnail = (FrameLayout) adapter.getView(i, null, parent);
parent.addView(thumbnail, i);
WallpaperTileInfo info = (WallpaperTileInfo) adapter.getItem(i);
thumbnail.setTag(info);
info.setView(thumbnail);
if (addLongPressHandler) {
addLongPressHandler(thumbnail);
}
thumbnail.setOnClickListener(mThumbnailOnClickListener);
}
}
public ViewHolder(View itemView) {
super(itemView);
name = (TextView) itemView.findViewById(R.id.name);
type = (TextView) itemView.findViewById(R.id.type);
size = (TextView) itemView.findViewById(R.id.size);
date = (TextView) itemView.findViewById(R.id.date);
thumbnail = (ImageView) itemView.findViewById(R.id.thumbNail);
frame = (FrameLayout) itemView.findViewById(R.id.frame);
frame.setTag(this);
animator = (ViewAnimator) itemView.findViewById(R.id.viewAnimator);
progressBar = (ProgressBar) itemView.findViewById(R.id.progressBar);
frame.setOnClickListener(this);
frame.setOnLongClickListener(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
context = this;
tracker = new LocationTracker(context);
setContentView(R.layout.activity_select_position);
mVisible = true;
mControlsView = findViewById(R.id.fullscreen_content_controls);
mContentView = (FrameLayout) findViewById(R.id.fullscreen_content);
MapFragment frag = (MapFragment) getSupportFragmentManager().findFragmentById(R.id.map_frag);
if (frag != null && mVisible){
frag.getView().setOnTouchListener(mDelayHideTouchListener);
}
// Set up the user interaction to manually show or hide the system UI.
mContentView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
toggle();
}
});
// Upon interacting with UI controls, delay any scheduled hide()
// operations to prevent the jarring behavior of controls going away
// while interacting with the UI.
setupViews();
}
private void initPageView() {
flPage = new FrameLayout(getContext());
flPage.setOnClickListener(this);
// 宫格列表的容器,为了“下对齐”,在外部包含了一个FrameLayout
LinearLayout llPage = new LinearLayout(getContext()) {
public boolean onTouchEvent(MotionEvent event) {
return true;
}
};
llPage.setOrientation(LinearLayout.VERTICAL);
int resId = getBitmapRes(getContext(), "share_vp_back");
if (resId > 0) {
llPage.setBackgroundResource(resId);
}
FrameLayout.LayoutParams lpLl = new FrameLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
lpLl.gravity = Gravity.BOTTOM;
llPage.setLayoutParams(lpLl);
flPage.addView(llPage);
// 宫格列表
grid = new PlatformGridView(getContext());
grid.setEditPageBackground(bgView);
LinearLayout.LayoutParams lpWg = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
grid.setLayoutParams(lpWg);
llPage.addView(grid);
// 取消按钮
btnCancel = new Button(getContext());
btnCancel.setTextColor(0xffffffff);
btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
resId = getStringRes(getContext(), "cancel");
if (resId > 0) {
btnCancel.setText(resId);
}
btnCancel.setPadding(0, 0, 0, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 5));
resId = getBitmapRes(getContext(), "btn_cancel_back");
if (resId > 0) {
btnCancel.setBackgroundResource(resId);
}
LinearLayout.LayoutParams lpBtn = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 45));
int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 10);
lpBtn.setMargins(dp_10, dp_10, dp_10, dp_10);
btnCancel.setLayoutParams(lpBtn);
llPage.addView(btnCancel);
}
/**
* Create a new instance.
*
* @param context The application environment.
* @param attrs A collection of attributes.
* @param defStyle The default style to apply to this view.
*/
public ActivityChooserView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mContext = context;
TypedArray attributesArray = context.obtainStyledAttributes(attrs,
R.styleable.SherlockActivityChooserView, defStyle, 0);
mInitialActivityCount = attributesArray.getInt(
R.styleable.SherlockActivityChooserView_initialActivityCount,
ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT);
Drawable expandActivityOverflowButtonDrawable = attributesArray.getDrawable(
R.styleable.SherlockActivityChooserView_expandActivityOverflowButtonDrawable);
attributesArray.recycle();
LayoutInflater inflater = LayoutInflater.from(mContext);
inflater.inflate(R.layout.abs__activity_chooser_view, this, true);
mCallbacks = new Callbacks();
mActivityChooserContent = (IcsLinearLayout) findViewById(R.id.abs__activity_chooser_view_content);
mActivityChooserContentBackground = mActivityChooserContent.getBackground();
mDefaultActivityButton = (FrameLayout) findViewById(R.id.abs__default_activity_button);
mDefaultActivityButton.setOnClickListener(mCallbacks);
mDefaultActivityButton.setOnLongClickListener(mCallbacks);
mDefaultActivityButtonImage = (ImageView) mDefaultActivityButton.findViewById(R.id.abs__image);
mExpandActivityOverflowButton = (FrameLayout) findViewById(R.id.abs__expand_activities_button);
mExpandActivityOverflowButton.setOnClickListener(mCallbacks);
mExpandActivityOverflowButtonImage =
(ImageView) mExpandActivityOverflowButton.findViewById(R.id.abs__image);
mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable);
mAdapter = new ActivityChooserViewAdapter();
mAdapter.registerDataSetObserver(new DataSetObserver() {
@Override
public void onChanged() {
super.onChanged();
updateAppearance();
}
});
Resources resources = context.getResources();
mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2,
resources.getDimensionPixelSize(R.dimen.abs__config_prefDialogWidth));
}
private void initPageView() {
flPage = new FrameLayout(getContext());
flPage.setOnClickListener(this);
// 宫格列表的容器,为了“下对齐”,在外部包含了一个FrameLayout
LinearLayout llPage = new LinearLayout(getContext()) {
public boolean onTouchEvent(MotionEvent event) {
return true;
}
};
llPage.setOrientation(LinearLayout.VERTICAL);
int resId = getBitmapRes(getContext(), "share_vp_back");
if (resId > 0) {
llPage.setBackgroundResource(resId);
}
FrameLayout.LayoutParams lpLl = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
lpLl.gravity = Gravity.BOTTOM;
llPage.setLayoutParams(lpLl);
flPage.addView(llPage);
// 宫格列表
grid = new PlatformGridView(getContext());
grid.setEditPageBackground(bgView);
LinearLayout.LayoutParams lpWg = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
grid.setLayoutParams(lpWg);
llPage.addView(grid);
// 取消按钮
btnCancel = new Button(getContext());
btnCancel.setTextColor(0xffffffff);
btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
resId = getStringRes(getContext(), "cancel");
if (resId > 0) {
btnCancel.setText(resId);
}
btnCancel.setPadding(0, 0, 0, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 5));
resId = getBitmapRes(getContext(), "btn_cancel_back");
if (resId > 0) {
btnCancel.setBackgroundResource(resId);
}
LinearLayout.LayoutParams lpBtn = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 45));
int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 10);
lpBtn.setMargins(dp_10, dp_10, dp_10, dp_10);
btnCancel.setLayoutParams(lpBtn);
llPage.addView(btnCancel);
}
private FrameLayout buttonForText(final boolean stroke, String text, boolean selected) {
FrameLayout button = new FrameLayout(getContext()) {
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return true;
}
};
button.setBackgroundDrawable(Theme.getSelectorDrawable(false));
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setStroke(stroke);
if (popupWindow != null && popupWindow.isShowing()) {
popupWindow.dismiss(true);
}
}
});
EditTextOutline textView = new EditTextOutline(getContext());
textView.setBackgroundColor(Color.TRANSPARENT);
textView.setEnabled(false);
textView.setStrokeWidth(AndroidUtilities.dp(3));
textView.setTextColor(stroke ? Color.WHITE : Color.BLACK);
textView.setStrokeColor(stroke ? Color.BLACK : Color.TRANSPARENT);
textView.setPadding(AndroidUtilities.dp(2), 0, AndroidUtilities.dp(2), 0);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
textView.setTypeface(null, Typeface.BOLD);
textView.setTag(stroke);
textView.setText(text);
button.addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 46, 0, 16, 0));
if (selected) {
ImageView check = new ImageView(getContext());
check.setImageResource(R.drawable.ic_ab_done);
check.setScaleType(ImageView.ScaleType.CENTER);
button.addView(check, LayoutHelper.createFrame(50, LayoutHelper.MATCH_PARENT));
}
return button;
}
private void initPageView() {
flPage = new FrameLayout(getContext());
flPage.setOnClickListener(this);
// container of the platform gridview
LinearLayout llPage = new LinearLayout(getContext()) {
public boolean onTouchEvent(MotionEvent event) {
return true;
}
};
llPage.setOrientation(LinearLayout.VERTICAL);
int resId = getBitmapRes(getContext(), "share_vp_back");
if (resId > 0) {
llPage.setBackgroundResource(resId);
}
FrameLayout.LayoutParams lpLl = new FrameLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
lpLl.gravity = Gravity.BOTTOM;
llPage.setLayoutParams(lpLl);
flPage.addView(llPage);
// gridview
grid = new PlatformGridView(getContext());
LinearLayout.LayoutParams lpWg = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
grid.setLayoutParams(lpWg);
llPage.addView(grid);
// cancel button
btnCancel = new Button(getContext());
btnCancel.setTextColor(0xffffffff);
btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
resId = getStringRes(getContext(), "cancel");
if (resId > 0) {
btnCancel.setText(resId);
}
btnCancel.setPadding(0, 0, 0, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 5));
resId = getBitmapRes(getContext(), "btn_cancel_back");
if (resId > 0) {
btnCancel.setBackgroundResource(resId);
}
LinearLayout.LayoutParams lpBtn = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 45));
int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 10);
lpBtn.setMargins(dp_10, dp_10, dp_10, dp_10);
btnCancel.setLayoutParams(lpBtn);
llPage.addView(btnCancel);
}
private void initView(View view) {
btnGetSign = (Button) view.findViewById(R.id.btn_get_sign);
btnGetSignChangeCoin = view.findViewById(R.id.btn_get_sign_change_coin);
btnCloneTo = (Button) view.findViewById(R.id.btn_clone_to);
btnCloneFrom = (Button) view.findViewById(R.id.btn_clone_from);
btnAdvance = (Button) view.findViewById(R.id.btn_advance);
ssvBitcoinUnit = (SettingSelectorView) view.findViewById(R.id.ssv_bitcoin_unit);
llQrForAll = (LinearLayout) view.findViewById(R.id.ll_qr_all_keys);
tvVersion = (TextView) view.findViewById(R.id.tv_version);
flBackTime = (FrameLayout) view.findViewById(R.id.ll_back_up);
pbBackTime = (ProgressBar) view.findViewById(R.id.pb_back_up);
setPbBackTimeSize();
String version = null;
try {
version = getActivity().getPackageManager().getPackageInfo(getActivity()
.getPackageName(), 0).versionName;
} catch (NameNotFoundException e) {
e.printStackTrace();
}
if (version != null) {
tvVersion.setText(version);
tvVersion.setVisibility(View.VISIBLE);
} else {
tvVersion.setVisibility(View.GONE);
}
tvPrivacyPolicy = (TextView) view.findViewById(R.id.tv_privacy_policy);
tvPrivacyPolicy.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
dp = new DialogProgress(getActivity(), R.string.please_wait);
btnGetSign.setOnClickListener(toSignActivityClickListener);
btnGetSignChangeCoin.setOnClickListener(toSignChangeCoinActivityClickListener);
btnCloneTo.setOnClickListener(cloneToClick);
btnCloneFrom.setOnClickListener(cloneFromClick);
llQrForAll.setOnClickListener(qrForAllClick);
btnAdvance.setOnClickListener(advanceClick);
ssvBitcoinUnit.setSelector(bitcoinUnitSelector);
tvBackupTime = (TextView) view.findViewById(R.id.tv_backup_time);
tvBackupPath = (TextView) view.findViewById(R.id.tv_backup_path);
flBackTime.setOnClickListener(backupTimeListener);
showBackupTime();
tvPrivacyPolicy.setOnClickListener(privacyPolicyClick);
}
/**
* Create a new instance.
*
* @param context The application environment.
* @param attrs A collection of attributes.
* @param defStyle The default style to apply to this view.
*/
public ActivityChooserView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mContext = context;
TypedArray attributesArray = context.obtainStyledAttributes(attrs,
R.styleable.SherlockActivityChooserView, defStyle, 0);
mInitialActivityCount = attributesArray.getInt(
R.styleable.SherlockActivityChooserView_initialActivityCount,
ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT);
Drawable expandActivityOverflowButtonDrawable = attributesArray.getDrawable(
R.styleable.SherlockActivityChooserView_expandActivityOverflowButtonDrawable);
attributesArray.recycle();
LayoutInflater inflater = LayoutInflater.from(mContext);
inflater.inflate(R.layout.abs__activity_chooser_view, this, true);
mCallbacks = new Callbacks();
mActivityChooserContent = (IcsLinearLayout) findViewById(R.id.abs__activity_chooser_view_content);
mActivityChooserContentBackground = mActivityChooserContent.getBackground();
mDefaultActivityButton = (FrameLayout) findViewById(R.id.abs__default_activity_button);
mDefaultActivityButton.setOnClickListener(mCallbacks);
mDefaultActivityButton.setOnLongClickListener(mCallbacks);
mDefaultActivityButtonImage = (ImageView) mDefaultActivityButton.findViewById(R.id.abs__image);
mExpandActivityOverflowButton = (FrameLayout) findViewById(R.id.abs__expand_activities_button);
mExpandActivityOverflowButton.setOnClickListener(mCallbacks);
mExpandActivityOverflowButtonImage =
(ImageView) mExpandActivityOverflowButton.findViewById(R.id.abs__image);
mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable);
mAdapter = new ActivityChooserViewAdapter();
mAdapter.registerDataSetObserver(new DataSetObserver() {
@Override
public void onChanged() {
super.onChanged();
updateAppearance();
}
});
Resources resources = context.getResources();
mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2,
resources.getDimensionPixelSize(R.dimen.abs__config_prefDialogWidth));
}
private void addMyCardsTitle() {
Context context = getContext();
int dp8 = RaadCommonUtils.getPx(8, context);
int dp16 = RaadCommonUtils.getPx(16, context);
LinearLayout layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams titleLayoutParams = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layout.setLayoutParams(titleLayoutParams);
layout.setGravity(Gravity.CENTER_VERTICAL);
layout.setPadding(dp16, dp8, dp16, dp16);
cardsLayout.addView(layout);
TextView title2 = new TextView(context);
LinearLayout.LayoutParams title2Params = new LinearLayout.LayoutParams(
0, LinearLayout.LayoutParams.WRAP_CONTENT);
title2Params.weight = 1.0f;
title2.setLayoutParams(title2Params);
title2.setTextColor(Color.parseColor(WalletActivity.textTitleTheme));
title2.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
title2.setTypeface(Typefaces.get(context, Typefaces.IRAN_YEKAN_BOLD));
title2.setText(R.string.my_cards);
layout.addView(title2);
FrameLayout addCardLayout = new FrameLayout(context);
int dp40 = RaadCommonUtils.getPx(40, context);
addCardLayout.setLayoutParams(new LinearLayout.LayoutParams(dp40, dp40));
addCardLayout.setPadding(dp8, dp8, dp8, dp8);
layout.addView(addCardLayout);
ImageView addCard = new ImageView(context);
addCard.setLayoutParams(new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
ViewCompat.setBackground(addCard, RaadCommonUtils.getRectShape(context, R.color.add_card_plus_back, 12, 0));
addCard.getBackground().setColorFilter(new PorterDuffColorFilter(Color.parseColor(WalletActivity.primaryColor), PorterDuff.Mode.SRC_IN));
addCard.setImageResource(R.drawable.ic_action_add_white);
int dp4 = RaadCommonUtils.getPx(4, context);
//addCard.setPadding(dp4, dp4, dp4, dp4);
addCardLayout.addView(addCard);
addCardLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
((NavigationBarActivity) getActivity()).pushFullFragment(
new AddCardFragment(), "AddCardFragment");
}
});
}
private FrameLayout initializeCroutonViewGroup(Resources resources) {
FrameLayout croutonView = new FrameLayout(this.activity);
if (null != onClickListener) {
croutonView.setOnClickListener(onClickListener);
}
final int height;
if (this.style.heightDimensionResId > 0) {
height = resources.getDimensionPixelSize(this.style.heightDimensionResId);
} else {
height = this.style.heightInPixels;
}
final int width;
if (this.style.widthDimensionResId > 0) {
width = resources.getDimensionPixelSize(this.style.widthDimensionResId);
} else {
width = this.style.widthInPixels;
}
croutonView.setLayoutParams(
new FrameLayout.LayoutParams(width != 0 ? width : FrameLayout.LayoutParams.MATCH_PARENT, height));
// set background
if (this.style.backgroundColorValue != Style.NOT_SET) {
croutonView.setBackgroundColor(this.style.backgroundColorValue);
} else {
croutonView.setBackgroundColor(resources.getColor(this.style.backgroundColorResourceId));
}
// set the background drawable if set. This will override the background
// color.
if (this.style.backgroundDrawableResourceId != 0) {
Bitmap background = BitmapFactory.decodeResource(resources, this.style.backgroundDrawableResourceId);
BitmapDrawable drawable = new BitmapDrawable(resources, background);
if (this.style.isTileEnabled) {
drawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
}
croutonView.setBackgroundDrawable(drawable);
}
return croutonView;
}