下面列出了android.widget.FrameLayout#setClickable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
protected void init(ViewGroup parent, int width, int height) {
if (!isDebug && (width <= 0 || height <= 0)) {
width = height = 1;
}
visible = (width != 1 && height != 1);
// 用于显示遮罩
mRootLayout = new FrameLayout(parent.getContext());
mRootLayout.setClickable(true);
parent.addView(mRootLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
// 用于加载网页
mWebView = new SafeWebView(parent.getContext());
mRootLayout.addView(mWebView, new FrameLayout.LayoutParams(width, height, Gravity.CENTER));
// 初始化
onInit();
}
@Override
public void onShowCustomView(View view, int requestedOrientation, final CustomViewCallback callback) {
FrameLayout container = new FrameLayout(mContext);
container.setBackgroundColor(0xff000000);
FrameLayout.LayoutParams parm = new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
container.setLayoutParams(parm);
container.setClickable(true);
container.addView(view);
// ((EBrowserActivity)mContext).requestWindowFeature()
WebViewSdkCompat.CustomViewCallback compatCallback=new WebViewSdkCompat.CustomViewCallback() {
@Override
public void onCustomViewHidden() {
callback.onCustomViewHidden();
}
};
((EBrowserActivity) mContext).showCustomView(container, compatCallback);
}
public void onShowCustomView(View view, int requestedOrientation, final CustomViewCallback callback) {
FrameLayout container = new FrameLayout(mContext);
container.setBackgroundColor(0xff000000);
FrameLayout.LayoutParams parm = new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
container.setLayoutParams(parm);
container.setClickable(true);
container.addView(view);
// ((EBrowserActivity)mContext).requestWindowFeature()
WebViewSdkCompat.CustomViewCallback compatCallback=new WebViewSdkCompat.CustomViewCallback() {
@Override
public void onCustomViewHidden() {
callback.onCustomViewHidden();
}
};
((EBrowserActivity) mContext).showCustomView(container, compatCallback);
}
private void initViews() {
decorView = ((Activity) context).getWindow().getDecorView().findViewById(android.R.id.content);
rootView = new FrameLayout(context);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT
);
rootView.setLayoutParams(layoutParams);
rootView.setClickable(true);
rootView.setBackgroundColor(context.getResources().getColor(R.color.btn_bg_press_tp));
mSharedView = new MoDialogView(context);
}
private void initViews() {
decorView = ((Activity) context).getWindow().getDecorView().findViewById(android.R.id.content);
rootView = new FrameLayout(context);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT
);
rootView.setLayoutParams(layoutParams);
rootView.setClickable(true);
rootView.setBackgroundColor(context.getResources().getColor(R.color.btn_bg_press_tp));
mSharedView = new MoDialogView(context);
}
public FrameLayout generateOverlayView() {
//Overlay view
FrameLayout mOverlayLayout = new FrameLayout(mContext);
mOverlayLayout.setLayoutParams(matchParams);
mOverlayLayout.animate().alpha(0);
mOverlayLayout.setVisibility(View.GONE);
mOverlayLayout.setClickable(true);
return mOverlayLayout;
}
@Override
public void addToLayout(ViewGroup layout)
{
LinearLayout container = new LinearLayout(getContext());
container.setOrientation(VERTICAL);
container.addView(mTitles);
container.addView(mSpinners);
addView(container);
if (!AccountUtil.isProUser(getContext())) {
FrameLayout splash = new FrameLayout(getContext());
splash.setClickable(true);
splash.setBackgroundColor(Color.argb(128, 128, 128, 128));
ImageView sign = new ImageView(getContext());
sign.setImageResource(R.drawable.ic_lock_black_24dp);
sign.setScaleType(ImageView.ScaleType.FIT_CENTER);
sign.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
ControlHelper.showProDialog(getContext());
}
});
splash.addView(sign);
addView(splash);
}
layout.addView(this);
}
@Override
public void onShowCustomView(View view, CustomViewCallback callback) {
super.onShowCustomView(view, callback);
if (owner == null) {
Clog.w(Clog.baseLogTag, Clog.getString(R.string.fullscreen_video_show_error));
return;
}
ViewGroup root = null;
if (owner != null) {
root = owner.getVideoAdView();
}
if (root == null) {
Clog.w(Clog.baseLogTag, Clog.getString(R.string.fullscreen_video_show_error));
return;
}
customViewCallback = callback;
if (view instanceof FrameLayout) {
frame = (FrameLayout) view;
frame.setClickable(true);
frame.setBackgroundColor(Color.BLACK);
try {
root.addView(frame);
} catch (Exception e) {
Clog.d(Clog.baseLogTag, e.toString());
}
} else {
frame = null;
}
}
public void disableBar(int index) {
final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount();
for (int i = 0; i < barsCount; i++) {
FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i);
int rootChildCount = rootFrame.getChildCount();
for (int j = 0; j < rootChildCount; j++) {
if ((int) rootFrame.getTag() != index)
continue;
rootFrame.setEnabled(false);
rootFrame.setClickable(false);
View childView = rootFrame.getChildAt(j);
if (childView instanceof LinearLayout) {
//bar
LinearLayout barContainerLinear = ((LinearLayout) childView);
int barContainerCount = barContainerLinear.getChildCount();
for (int k = 0; k < barContainerCount; k++) {
View view = barContainerLinear.getChildAt(k);
if (view instanceof Bar) {
Bar bar = (Bar) view;
LayerDrawable layerDrawable = (LayerDrawable) bar.getProgressDrawable();
layerDrawable.mutate();
ScaleDrawable scaleDrawable = (ScaleDrawable) layerDrawable.getDrawable(1);
GradientDrawable progressLayer = (GradientDrawable) scaleDrawable.getDrawable();
if (progressLayer != null) {
if (mProgressDisableColor > 0)
progressLayer.setColor(ContextCompat.getColor(mContext, mProgressDisableColor));
else
progressLayer.setColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
}
} else {
TextView titleTxtView = (TextView) view;
if (mProgressDisableColor > 0)
titleTxtView.setTextColor(ContextCompat.getColor(mContext, mProgressDisableColor));
else
titleTxtView.setTextColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
}
}
}
}
}
}
public void enableBar(int index) {
final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount();
for (int i = 0; i < barsCount; i++) {
FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i);
int rootChildCount = rootFrame.getChildCount();
for (int j = 0; j < rootChildCount; j++) {
if ((int) rootFrame.getTag() != index)
continue;
rootFrame.setEnabled(true);
rootFrame.setClickable(true);
View childView = rootFrame.getChildAt(j);
if (childView instanceof LinearLayout) {
//bar
LinearLayout barContainerLinear = ((LinearLayout) childView);
int barContainerCount = barContainerLinear.getChildCount();
for (int k = 0; k < barContainerCount; k++) {
View view = barContainerLinear.getChildAt(k);
if (view instanceof Bar) {
Bar bar = (Bar) view;
LayerDrawable layerDrawable = (LayerDrawable) bar.getProgressDrawable();
layerDrawable.mutate();
ScaleDrawable scaleDrawable = (ScaleDrawable) layerDrawable.getDrawable(1);
GradientDrawable progressLayer = (GradientDrawable) scaleDrawable.getDrawable();
if (progressLayer != null) {
if (mProgressColor > 0)
progressLayer.setColor(ContextCompat.getColor(mContext, mProgressColor));
else
progressLayer.setColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
}
} else {
TextView titleTxtView = (TextView) view;
if (mProgressDisableColor > 0)
titleTxtView.setTextColor(ContextCompat.getColor(mContext, mBarTitleColor));
else
titleTxtView.setTextColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
}
}
}
}
}
}
private void initItemView(SettingViewItemData data) {
FrameLayout itemView = data.getItemView();
if (itemView instanceof SwitchItemView) {
((SwitchItemView) itemView).fillData(data.getData());
itemView.setClickable(false);
((SwitchItemView) itemView).setOnSwitchItemChangedListener(new onSwitchItemChangedListener() {
@Override
public void onSwitchItemChanged(boolean isChecked) {
// TODO Auto-generated method stub
if (null != mSettingButtonSwitchListener) {
mSettingButtonSwitchListener.onSwitchChanged(isChecked);
}
}
});
} else {
itemView.setClickable(data.isClickable());
itemView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (null != mSettingButtonClickListener) {
mSettingButtonClickListener.onSettingButtonClick();
}
}
});
if (itemView instanceof BasicItemViewH) {
((BasicItemViewH) itemView).fillData(data.getData());
} else if (itemView instanceof BasicItemViewV) {
((BasicItemViewV) itemView).fillData(data.getData());
} else if (itemView instanceof ImageItemView) {
((ImageItemView) itemView).fillData(data.getData());
} else if (itemView instanceof CheckItemViewH) {
((CheckItemViewH) itemView).fillData(data.getData());
} else if (itemView instanceof CheckItemViewV) {
((CheckItemViewV) itemView).fillData(data.getData());
}
}
int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.setting_view_min_height), getResources().getDisplayMetrics());
LinearLayout.LayoutParams lps = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, height);
addView(itemView, lps);
}
private void initItemView(SettingViewItemData data, final int index) {
FrameLayout itemView = data.getItemView();
if (itemView instanceof SwitchItemView) {
((SwitchItemView) itemView).fillData(data.getData());
((SwitchItemView) itemView).setOnSwitchItemChangedListener(new onSwitchItemChangedListener() {
@Override
public void onSwitchItemChanged(boolean isChecked) {
// TODO Auto-generated method stub
if (null != mItemSwitchListener) {
mItemSwitchListener.onSwitchChanged(index, isChecked);
}
}
});
itemView.setClickable(false);
} else {
itemView.setClickable(data.isClickable());
itemView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (null != mItemClickListener) {
mItemClickListener.onItemClick(index);
}
}
});
if (itemView instanceof BasicItemViewH) {
((BasicItemViewH) itemView).fillData(data.getData());
} else if (itemView instanceof BasicItemViewV) {
((BasicItemViewV) itemView).fillData(data.getData());
} else if (itemView instanceof ImageItemView) {
((ImageItemView) itemView).fillData(data.getData());
} else if (itemView instanceof CheckItemViewH) {
((CheckItemViewH) itemView).fillData(data.getData());
} else if (itemView instanceof CheckItemViewV) {
((CheckItemViewV) itemView).fillData(data.getData());
}
}
int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.setting_view_min_height), getResources().getDisplayMetrics());
LinearLayout.LayoutParams lps = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, height);
addView(itemView, lps);
}