android.widget.FrameLayout#setBackgroundDrawable ( )源码实例Demo

下面列出了android.widget.FrameLayout#setBackgroundDrawable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: SETransitionDemo   文件: DestinationActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        postponeEnterTransition();
    }
    setContentView(R.layout.activity_destination);
    FrameLayout container = (FrameLayout) findViewById(R.id.container);
    colorDrawable = new ColorDrawable(getResources().getColor(R.color.colorPrimaryDark));
    container.setBackgroundDrawable(colorDrawable);

    Intent intent = getIntent();
    ArrayList<Uri> uris = intent.getParcelableArrayListExtra("uris");
    adapterPosition = intent.getIntExtra("adapter_position", 0);
    current = intent.getIntExtra("current", 0);

    viewPager = (ViewPager) findViewById(R.id.viewPager);
    viewPager.setAdapter(new PhotoAdapter(uris, onDismissListener));
    viewPager.setCurrentItem(current);
}
 
源代码2 项目: hover   文件: ContentDisplay.java
private void init() {
    LayoutInflater.from(getContext()).inflate(R.layout.view_hover_menu_content, this, true);

    mContainer = findViewById(R.id.container);
    expandToScreenBounds();

    int backgroundCornerRadiusPx = (int) getResources().getDimension(R.dimen.hover_navigator_corner_radius);
    mTabSelectorView = (TabSelectorView) findViewById(R.id.tabselector);
    mTabSelectorView.setPadding(backgroundCornerRadiusPx, 0, backgroundCornerRadiusPx, 0);

    mContentView = (FrameLayout) findViewById(R.id.view_content_container);
    mContentBackground = ContextCompat.getDrawable(getContext(), R.drawable.round_rect_white);
    mContentView.setBackgroundDrawable(mContentBackground);

    getViewTreeObserver().addOnGlobalLayoutListener(mMyVisibilityWatcher);
}
 
源代码3 项目: Telegram-FOSS   文件: LocationDirectionCell.java
public LocationDirectionCell(Context context) {
    super(context);

    frameLayout = new FrameLayout(context);
    frameLayout.setBackgroundDrawable(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(4), Theme.getColor(Theme.key_featuredStickers_addButton), Theme.getColor(Theme.key_featuredStickers_addButtonPressed)));
    addView(frameLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.TOP, 16, 10, 16, 0));

    buttonTextView = new SimpleTextView(context);
    buttonTextView.setPadding(AndroidUtilities.dp(34), 0, AndroidUtilities.dp(34), 0);
    buttonTextView.setGravity(Gravity.CENTER);
    buttonTextView.setDrawablePadding(AndroidUtilities.dp(8));
    buttonTextView.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText));
    buttonTextView.setTextSize(14);
    buttonTextView.setText(LocaleController.getString("Directions", R.string.Directions));
    buttonTextView.setLeftDrawable(R.drawable.navigate);
    buttonTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    frameLayout.addView(buttonTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
}
 
源代码4 项目: Telegram   文件: LocationDirectionCell.java
public LocationDirectionCell(Context context) {
    super(context);

    frameLayout = new FrameLayout(context);
    frameLayout.setBackgroundDrawable(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(4), Theme.getColor(Theme.key_featuredStickers_addButton), Theme.getColor(Theme.key_featuredStickers_addButtonPressed)));
    addView(frameLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.TOP, 16, 10, 16, 0));

    buttonTextView = new SimpleTextView(context);
    buttonTextView.setPadding(AndroidUtilities.dp(34), 0, AndroidUtilities.dp(34), 0);
    buttonTextView.setGravity(Gravity.CENTER);
    buttonTextView.setDrawablePadding(AndroidUtilities.dp(8));
    buttonTextView.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText));
    buttonTextView.setTextSize(14);
    buttonTextView.setText(LocaleController.getString("Directions", R.string.Directions));
    buttonTextView.setLeftDrawable(R.drawable.navigate);
    buttonTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    frameLayout.addView(buttonTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
}
 
源代码5 项目: TelePlus-Android   文件: PhotoPaintView.java
private FrameLayout buttonForBrush(final int brush, int resource, boolean selected) {
    FrameLayout button = new FrameLayout(getContext());
    button.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setBrush(brush);

            if (popupWindow != null && popupWindow.isShowing()) {
                popupWindow.dismiss(true);
            }
        }
    });

    ImageView preview = new ImageView(getContext());
    preview.setImageResource(resource);
    button.addView(preview, LayoutHelper.createFrame(165, 44, Gravity.LEFT | Gravity.CENTER_VERTICAL, 46, 0, 8, 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;
}
 
源代码6 项目: TelePlus-Android   文件: PhotoPaintView.java
private FrameLayout buttonForBrush(final int brush, int resource, boolean selected) {
    FrameLayout button = new FrameLayout(getContext());
    button.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setBrush(brush);

            if (popupWindow != null && popupWindow.isShowing()) {
                popupWindow.dismiss(true);
            }
        }
    });

    ImageView preview = new ImageView(getContext());
    preview.setImageResource(resource);
    button.addView(preview, LayoutHelper.createFrame(165, 44, Gravity.LEFT | Gravity.CENTER_VERTICAL, 46, 0, 8, 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;
}
 
源代码7 项目: BubbleAlert   文件: BblDialogFragmentBase.java
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    container = (FrameLayout) view;
    containerLayoutParams = new FrameLayout.LayoutParams(getWidth(), getHeight());
    container.setBackgroundDrawable(alertDrawable);
}
 
源代码8 项目: PkRequestManager   文件: IntermediateActivity.java
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
private void selectCard(boolean Selected, FrameLayout Card)
{
	// Use new API beyond Jelly Bean but keep compatibility with ICS
	if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
		Card.setBackgroundDrawable(Selected ? mRes.getDrawable(R.drawable.card_bg_selected) : mRes.getDrawable(R.drawable.card_bg));
	}
	else {
		Card.setBackground(Selected ? mRes.getDrawable(R.drawable.card_bg_selected) : mRes.getDrawable(R.drawable.card_bg));
	}
}
 
源代码9 项目: PkRequestManager   文件: AdvancedActivity.java
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
private void selectCard(boolean Selected, FrameLayout Card)
{
	if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
		Card.setBackgroundDrawable(Selected ? mRes.getDrawable(R.drawable.card_bg_selected) : mRes.getDrawable(R.drawable.card_bg));
	else
		Card.setBackground(Selected ? mRes.getDrawable(R.drawable.card_bg_selected) : mRes.getDrawable(R.drawable.card_bg));
}
 
源代码10 项目: Telegram-FOSS   文件: PhotoPaintView.java
private FrameLayout buttonForBrush(final int brush, int resource, boolean applyColor, boolean selected) {
    FrameLayout button = new FrameLayout(getContext());
    button.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    button.setOnClickListener(v -> {
        setBrush(brush);

        if (popupWindow != null && popupWindow.isShowing()) {
            popupWindow.dismiss(true);
        }
    });

    ImageView preview = new ImageView(getContext());
    preview.setImageResource(resource);
    if (applyColor) {
        preview.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), PorterDuff.Mode.SRC_IN));
    }
    button.addView(preview, LayoutHelper.createFrame(165, 44, Gravity.LEFT | Gravity.CENTER_VERTICAL, 46, 0, 8, 0));

    if (selected) {
        ImageView check = new ImageView(getContext());
        check.setImageResource(R.drawable.ic_ab_done);
        check.setScaleType(ImageView.ScaleType.CENTER);
        check.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY));
        button.addView(check, LayoutHelper.createFrame(50, LayoutHelper.MATCH_PARENT));
    }

    return button;
}
 
源代码11 项目: Telegram   文件: PhotoPaintView.java
private FrameLayout buttonForBrush(final int brush, int resource, boolean applyColor, boolean selected) {
    FrameLayout button = new FrameLayout(getContext());
    button.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    button.setOnClickListener(v -> {
        setBrush(brush);

        if (popupWindow != null && popupWindow.isShowing()) {
            popupWindow.dismiss(true);
        }
    });

    ImageView preview = new ImageView(getContext());
    preview.setImageResource(resource);
    if (applyColor) {
        preview.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), PorterDuff.Mode.SRC_IN));
    }
    button.addView(preview, LayoutHelper.createFrame(165, 44, Gravity.LEFT | Gravity.CENTER_VERTICAL, 46, 0, 8, 0));

    if (selected) {
        ImageView check = new ImageView(getContext());
        check.setImageResource(R.drawable.ic_ab_done);
        check.setScaleType(ImageView.ScaleType.CENTER);
        check.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY));
        button.addView(check, LayoutHelper.createFrame(50, LayoutHelper.MATCH_PARENT));
    }

    return button;
}
 
源代码12 项目: dingo   文件: TrashView.java
/**
 * コンストラクタ
 *
 * @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 = OVERLAY_TYPE;
    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 LayoutParams backgroundParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (BACKGROUND_HEIGHT * mMetrics.density));
    backgroundParams.gravity = Gravity.BOTTOM;
    mRootView.addView(mBackgroundView, backgroundParams);
    // アクションアイコンの貼り付け
    final LayoutParams actionTrashIconParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    actionTrashIconParams.gravity = Gravity.CENTER;
    mTrashIconRootView.addView(mActionTrashIconView, actionTrashIconParams);
    // 固定アイコンの貼付け
    final LayoutParams fixedTrashIconParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    fixedTrashIconParams.gravity = Gravity.CENTER;
    mTrashIconRootView.addView(mFixedTrashIconView, fixedTrashIconParams);
    // 削除アイコンの貼り付け
    final LayoutParams trashIconParams = new 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);
}
 
源代码13 项目: TelePlus-Android   文件: PhotoPaintView.java
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;
}
 
源代码14 项目: TelePlus-Android   文件: PhotoPaintView.java
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;
}
 
源代码15 项目: BigApp_Discuz_Android   文件: PlatformListPage.java
private void initPageView() {
	flPage = new FrameLayout(getContext());
	flPage.setOnClickListener(this);
	flPage.setBackgroundDrawable(new ColorDrawable(0x55000000));

	// container of the platform gridview
	llPage = new LinearLayout(getContext()) {
		public boolean onTouchEvent(MotionEvent event) {
			return true;
		}
	};
	llPage.setOrientation(LinearLayout.VERTICAL);
	llPage.setBackgroundDrawable(new ColorDrawable(0xffffffff));
	FrameLayout.LayoutParams lpLl = new FrameLayout.LayoutParams(
			FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
	lpLl.gravity = Gravity.BOTTOM;
	llPage.setLayoutParams(lpLl);
	flPage.addView(llPage);

	// gridview
	grid = new PlatformGridView(getContext());
	grid.setEditPageBackground(getBackgroundView());
	LinearLayout.LayoutParams lpWg = new LinearLayout.LayoutParams(
			LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
	grid.setLayoutParams(lpWg);
	llPage.addView(grid);

	// cancel button
	btnCancel = new Button(getContext());
	btnCancel.setTextColor(0xff3a65ff);
	btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
	int resId = getStringRes(getContext(), "cancel");
	if (resId > 0) {
		btnCancel.setText(resId);
	}
	btnCancel.setPadding(0, 0, 0, com.mob.tools.utils.R.dipToPx(getContext(), 5));

	resId = getBitmapRes(getContext(), "classic_platform_corners_bg");
	if(resId > 0){
		btnCancel.setBackgroundResource(resId);
	}else {
	    btnCancel.setBackgroundDrawable(new ColorDrawable(0xffffffff));
	}

	LinearLayout.LayoutParams lpBtn = new LinearLayout.LayoutParams(
			LinearLayout.LayoutParams.MATCH_PARENT, com.mob.tools.utils.R.dipToPx(getContext(), 45));
	int dp_10 = com.mob.tools.utils.R.dipToPx(getContext(), 10);
	lpBtn.setMargins(dp_10, dp_10, dp_10, dp_10);
	btnCancel.setLayoutParams(lpBtn);
	llPage.addView(btnCancel);
}
 
private void initPageView() {
		flPage = new FrameLayout(getContext());
		flPage.setOnClickListener(this);
		flPage.setBackgroundDrawable(new ColorDrawable(0x55000000));

		// container of the platform gridview
		llPage = new LinearLayout(getContext()) {
			public boolean onTouchEvent(MotionEvent event) {
				return true;
			}
		};
		llPage.setOrientation(LinearLayout.VERTICAL);
		llPage.setBackgroundDrawable(new ColorDrawable(0xffffffff));
		FrameLayout.LayoutParams lpLl = new FrameLayout.LayoutParams(
				FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
		lpLl.gravity = Gravity.BOTTOM;
		llPage.setLayoutParams(lpLl);
		flPage.addView(llPage);

		// gridview
		grid = new PlatformGridView(getContext());
		grid.setEditPageBackground(getBackgroundView());
		LinearLayout.LayoutParams lpWg = new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
		grid.setLayoutParams(lpWg);
		llPage.addView(grid);

		View line_view = new View(getContext());
		line_view.setBackgroundDrawable(new ColorDrawable(0xffd5d5d5));

		int lineHeight = (int)((float)0.5 * getContext().getResources().getDisplayMetrics().density + 0.5F);

		LinearLayout.LayoutParams lpLine = new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.MATCH_PARENT, lineHeight);
		int dp_10 = com.mob.tools.utils.R.dipToPx(getContext(), 10);
		lpLine.setMargins(0, dp_10, 0, 0);
		line_view.setLayoutParams(lpLine);
		llPage.addView(line_view);

		// cancel button
		btnCancel = new Button(getContext());
		ColorStateList csl=(ColorStateList)activity.getResources().getColorStateList(R.color.z_txt_input);
		btnCancel.setTextColor(csl);
		btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
		int resId = getStringRes(getContext(), "cancel");
		if (resId > 0) {
			btnCancel.setText(resId);
		}
		btnCancel.setPadding(0, 0, 0, 0);

		resId = getBitmapRes(getContext(), "classic_platform_corners_bg");
		if(resId > 0){
			btnCancel.setBackgroundResource(resId);
		}else {
		    btnCancel.setBackgroundDrawable(new ColorDrawable(0xffffffff));
		}
		btnCancel.setBackgroundColor(0x00ffffff);

		LinearLayout.LayoutParams lpBtn = new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.MATCH_PARENT, com.mob.tools.utils.R.dipToPx(getContext(), 45));
//		int dp_10 = com.mob.tools.utils.R.dipToPx(getContext(), 10);
		lpBtn.setMargins(0, 0, 0, 0);
		btnCancel.setLayoutParams(lpBtn);
		llPage.addView(btnCancel);
	}
 
源代码17 项目: FloatingView   文件: TrashView.java
/**
 * コンストラクタ
 *
 * @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 = OVERLAY_TYPE;
    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);
}
 
源代码18 项目: TiCrouton   文件: Crouton.java
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;
}
 
@SuppressWarnings("deprecation")
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
	convertView = mViews[position];
	if(convertView == null){
		
		AnimatedScaleDrawable drawable = new AnimatedScaleDrawable(
			parent.getContext().getResources().getDrawable(R.drawable.heart));
		drawable.setInterpolator(new BounceInterpolator());
		drawable.setInvertTransformation(true);
		drawable.setDuration(500);
		
		FrameLayout frame = (FrameLayout)LayoutInflater.from(parent.getContext())
			.inflate(R.layout.item_frame, parent, false);
		
		if(position == 0){
			// ProgressBar example
			ProgressBar progress = (ProgressBar)LayoutInflater.from(parent.getContext())
				.inflate(R.layout.item_progress, frame, false);
			progress.setIndeterminateDrawable(drawable);
			frame.addView(progress);
		}
		else{
			if(position == 1 || position == 2){
				// Background drawable example
				frame.setBackgroundDrawable(drawable);
				if(position == 2){
					drawable.setUseBounds(false);
				}
			}else{
				// Foreground's with Gravity example
				frame.setForeground(drawable);
				frame.setForegroundGravity(mGravity[position - 3]);
			}
			// no need to call drawable.start() for ProgressBar widgets
			drawable.start();
		}
		
		TextView textView = (TextView)frame.findViewById(R.id.text);
		textView.setText(String.format("#%02d %s", position, mNames[position]));
		
		convertView = frame;
	}
	
	return convertView;
}