Java Code Examples for android.widget.FrameLayout#setBackgroundDrawable()

The following examples show how to use android.widget.FrameLayout#setBackgroundDrawable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocationDirectionCell.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
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));
}
 
Example 2
Source File: LocationDirectionCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
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));
}
 
Example 3
Source File: DestinationActivity.java    From SETransitionDemo with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 4
Source File: ContentDisplay.java    From hover with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 5
Source File: PhotoPaintView.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 6
Source File: PhotoPaintView.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 7
Source File: AdvancedActivity.java    From PkRequestManager with MIT License 5 votes vote down vote up
@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));
}
 
Example 8
Source File: IntermediateActivity.java    From PkRequestManager with MIT License 5 votes vote down vote up
@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));
	}
}
 
Example 9
Source File: BblDialogFragmentBase.java    From BubbleAlert with MIT License 5 votes vote down vote up
@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);
}
 
Example 10
Source File: PhotoPaintView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 11
Source File: PhotoPaintView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 12
Source File: PlatformListPage.java    From BigApp_WordPress_Android with Apache License 2.0 4 votes vote down vote up
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);
	}
 
Example 13
Source File: PlatformListPage.java    From BigApp_Discuz_Android with Apache License 2.0 4 votes vote down vote up
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);
}
 
Example 14
Source File: TrashView.java    From FloatingView with Apache License 2.0 4 votes vote down vote up
/**
 * コンストラクタ
 *
 * @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);
}
 
Example 15
Source File: PhotoPaintView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example 16
Source File: PhotoPaintView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example 17
Source File: Crouton.java    From TiCrouton with MIT License 4 votes vote down vote up
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;
}
 
Example 18
Source File: MainActivity.java    From android-animatedscaledrawable with Apache License 2.0 4 votes vote down vote up
@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;
}
 
Example 19
Source File: TrashView.java    From dingo with GNU General Public License v3.0 4 votes vote down vote up
/**
 * コンストラクタ
 *
 * @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);
}