下面列出了android.widget.FrameLayout#getContext ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Create a color change animation over a foreground property of a {@link FrameLayout}.
*
* @param target The target view.
* @param startColorRes The color to start from.
* @param targetColorRes The color this animation will end with.
* @param interpolator The interpolator to use.
* @return The color change animation.
*/
@NonNull
public static ObjectAnimator createColorChange(@NonNull FrameLayout target,
@ColorRes int startColorRes,
@ColorRes int targetColorRes,
@NonNull Interpolator interpolator) {
Context context = target.getContext();
final int startColor = ContextCompat.getColor(context, startColorRes);
final int targetColor = ContextCompat.getColor(context, targetColorRes);
ObjectAnimator colorChange = ObjectAnimator.ofInt(target,
ViewUtils.FOREGROUND_COLOR, startColor, targetColor);
colorChange.setEvaluator(new ArgbEvaluator());
colorChange.setInterpolator(interpolator);
colorChange.setDuration(context.getResources()
.getInteger(android.R.integer.config_longAnimTime));
return colorChange;
}
/**
* {@inheritDoc}
*/
@Override
public void init(@NonNull FrameLayout parent) {
mSurfaceView = new TransformableSurfaceView(parent.getContext());
mSurfaceView.setLayoutParams(
new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT));
parent.addView(mSurfaceView);
mSurfaceView.getHolder().addCallback(mSurfaceRequestCallback);
}
protected void addBackgroundChild(FrameLayout frameLayout) {
TextView textView = new TextView(frameLayout.getContext());
textView.setText("技术由 AgentWeb 提供");
textView.setTextSize(16);
textView.setTextColor(Color.parseColor("#727779"));
frameLayout.setBackgroundColor(Color.parseColor("#272b2d"));
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(-2, -2);
params.gravity = Gravity.CENTER_HORIZONTAL;
final float scale = frameLayout.getContext().getResources().getDisplayMetrics().density;
params.topMargin = (int) (15 * scale + 0.5f);
frameLayout.addView(textView, 0, params);
}
protected void addBackgroundChild(FrameLayout frameLayout) {
TextView textView = new TextView(frameLayout.getContext());
textView.setText("技术由 AgentWeb 提供");
textView.setTextSize(16);
textView.setTextColor(Color.parseColor("#727779"));
frameLayout.setBackgroundColor(Color.parseColor("#272b2d"));
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(-2, -2);
params.gravity = Gravity.CENTER_HORIZONTAL;
final float scale = frameLayout.getContext().getResources().getDisplayMetrics().density;
params.topMargin = (int) (15 * scale + 0.5f);
frameLayout.addView(textView, 0, params);
}
protected void addBGChild(FrameLayout frameLayout) {
TextView mTextView = new TextView(frameLayout.getContext());
mTextView.setText("技术由 AgentWeb 提供");
mTextView.setTextSize(16);
mTextView.setTextColor(Color.parseColor("#727779"));
frameLayout.setBackgroundColor(Color.parseColor("#272b2d"));
FrameLayout.LayoutParams mFlp = new FrameLayout.LayoutParams(-2, -2);
mFlp.gravity = Gravity.CENTER_HORIZONTAL;
final float scale = frameLayout.getContext().getResources().getDisplayMetrics().density;
mFlp.topMargin = (int) (15 * scale + 0.5f);
frameLayout.addView(mTextView, 0, mFlp);
}
/**
* 设置下拉回弹的文字
*/
protected void addBgChild(FrameLayout frameLayout) {
TextView textView = new TextView(frameLayout.getContext());
textView.setText(R.string.articleActivity_support);
textView.setTextSize(16);
textView.setTextColor(Color.parseColor("#727779"));
frameLayout.setBackgroundColor(Color.parseColor("#272b2d"));
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(-2, -2);
params.gravity = Gravity.CENTER_HORIZONTAL;
final float scale = frameLayout.getContext().getResources().getDisplayMetrics().density;
params.topMargin = (int) (30 * scale + 0.5f);
frameLayout.addView(textView, 0, params);
}
@Override
public View onCreateEmptyView(FrameLayout parent)
{
TextView textView = new TextView(parent.getContext());
textView.setText(mEmptyText);
textView.setTextColor(mTextColor);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setGravity(Gravity.CENTER);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.CENTER;
textView.setLayoutParams(params);
return textView;
}
protected void addBGChild(FrameLayout frameLayout) {
TextView mTextView = new TextView(frameLayout.getContext());
mTextView.setText("技术由 AgentWeb 提供");
mTextView.setTextSize(16);
mTextView.setTextColor(Color.parseColor("#727779"));
frameLayout.setBackgroundColor(Color.parseColor("#272b2d"));
FrameLayout.LayoutParams mFlp = new FrameLayout.LayoutParams(-2, -2);
mFlp.gravity = Gravity.CENTER_HORIZONTAL;
final float scale = frameLayout.getContext().getResources().getDisplayMetrics().density;
mFlp.topMargin = (int) (15 * scale + 0.5f);
frameLayout.addView(mTextView, 0, mFlp);
}
private void initView(FrameLayout frameLayout) {
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
layoutParams.gravity = Gravity.CENTER;
/* 图片加载进度圈 */
CircleProgress progress = getProgressView(getActivity());
mProgressModelLoader = new ProgressModelLoader(getHandler(progress));
if (url.endsWith(".gif")) {
GifMovieView gifView = new GifMovieView(frameLayout.getContext());
gifView.setLayoutParams(layoutParams);
gifView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// 点击图片返回
getActivity().onBackPressed();
}
});
frameLayout.addView(gifView);
progress.inject(gifView);
loadPic(url, gifView, true);
} else {
PhotoView photoView = new PhotoView(frameLayout.getContext());
photoView.setLayoutParams(layoutParams);
photoView.setOnPhotoTapListener(new OnPhotoTapListener() {
@Override
public void onPhotoTap(ImageView view, float x, float y) {
// 点击图片返回
getActivity().onBackPressed();
}
});
frameLayout.addView(photoView);
progress.inject(photoView);
loadPic(url, photoView, false);
}
}
public EBrowserWidgetPool(EBrowser inBrw, FrameLayout window,
EBrowserAround inShelter) {
mBrw = inBrw;
mNativeWindow = window;
mBrowserAround = inShelter;
mSpaceWidgetResu = new EWgtResultInfo(null, null);
mWgtStack = new EWidgetStack();
mContext = (EBrowserActivity) window.getContext();
mWidPoolLoop = new PoolHandler(Looper.getMainLooper());
mEBrowserWidgetPool=this;
}