本文整理汇总了Java中android.widget.FrameLayout.setAlpha方法的典型用法代码示例。如果您正苦于以下问题:Java FrameLayout.setAlpha方法的具体用法?Java FrameLayout.setAlpha怎么用?Java FrameLayout.setAlpha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.FrameLayout
的用法示例。
在下文中一共展示了FrameLayout.setAlpha方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TrashView
import android.widget.FrameLayout; //导入方法依赖的package包/类
/**
* コンストラクタ
*
* @param context Context
*/
TrashView(Context context) {
super(context);
mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
mMetrics = new DisplayMetrics();
mWindowManager.getDefaultDisplay().getMetrics(mMetrics);
mAnimationHandler = new AnimationHandler(this);
mIsEnabled = true;
mParams = new WindowManager.LayoutParams();
mParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
mParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
mParams.type = WindowManager.LayoutParams.TYPE_PRIORITY_PHONE;
mParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
mParams.format = PixelFormat.TRANSLUCENT;
// INFO:Windowの原点のみ左下に設定
mParams.gravity = Gravity.LEFT | Gravity.BOTTOM;
// 各種Viewの設定
// TrashViewに直接貼り付けられるView(このViewを介さないと、削除Viewと背景Viewのレイアウトがなぜか崩れる)
mRootView = new FrameLayout(context);
mRootView.setClipChildren(false);
// 削除アイコンのルートView
mTrashIconRootView = new FrameLayout(context);
mTrashIconRootView.setClipChildren(false);
mFixedTrashIconView = new ImageView(context);
mActionTrashIconView = new ImageView(context);
// 背景View
mBackgroundView = new FrameLayout(context);
mBackgroundView.setAlpha(0.0f);
final GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[]{0x00000000, 0x50000000});
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
//noinspection deprecation
mBackgroundView.setBackgroundDrawable(gradientDrawable);
} else {
mBackgroundView.setBackground(gradientDrawable);
}
// 背景Viewの貼り付け
final FrameLayout.LayoutParams backgroundParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (BACKGROUND_HEIGHT * mMetrics.density));
backgroundParams.gravity = Gravity.BOTTOM;
mRootView.addView(mBackgroundView, backgroundParams);
// アクションアイコンの貼り付け
final FrameLayout.LayoutParams actionTrashIconParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
actionTrashIconParams.gravity = Gravity.CENTER;
mTrashIconRootView.addView(mActionTrashIconView, actionTrashIconParams);
// 固定アイコンの貼付け
final FrameLayout.LayoutParams fixedTrashIconParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
fixedTrashIconParams.gravity = Gravity.CENTER;
mTrashIconRootView.addView(mFixedTrashIconView, fixedTrashIconParams);
// 削除アイコンの貼り付け
final FrameLayout.LayoutParams trashIconParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
trashIconParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
mRootView.addView(mTrashIconRootView, trashIconParams);
// TrashViewに貼り付け
addView(mRootView);
// 初回描画処理用
getViewTreeObserver().addOnPreDrawListener(this);
}