android.graphics.drawable.ColorDrawable Java Examples

The following examples show how to use android.graphics.drawable.ColorDrawable. 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: ImageSrcAttr.java    From Android-Skin with MIT License 6 votes vote down vote up
@Override
public void apply(View view) {
    if (view instanceof ImageView) {
        ImageView imageView = (ImageView) view;
        if (RES_TYPE_NAME_DRAWABLE.equals(attrValueTypeName)) {
            Drawable bg = AndroidSkin.getInstance().getSkinDrawable(
                    attrValueTypeName, attrValueRefName, attrValueRefId);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                imageView.setImageDrawable(bg);
            } else {
                imageView.setImageDrawable(bg);
            }
        }else if (RES_TYPE_NAME_COLOR.equals(attrValueTypeName)){
            int color = AndroidSkin.getInstance().
                    getSkinColor(attrValueTypeName, attrValueRefName, attrValueRefId);
            imageView.setImageDrawable(new ColorDrawable(color));
        }
    }else {
        LogUtils.d(TAG,"ImageSrcAttr apply src not ImageView! ");
    }

}
 
Example #2
Source File: BaseActivity.java    From Toutiao with Apache License 2.0 6 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    int color = SettingUtil.getInstance().getColor();
    int drawable = Constant.ICONS_DRAWABLES[SettingUtil.getInstance().getCustomIconValue()];
    if (getSupportActionBar() != null)
        getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().setStatusBarColor(CircleView.shiftColorDown(color));
        // 最近任务栏上色
        ActivityManager.TaskDescription tDesc = new ActivityManager.TaskDescription(
                getString(R.string.app_name),
                BitmapFactory.decodeResource(getResources(), drawable),
                color);
        setTaskDescription(tDesc);
        if (SettingUtil.getInstance().getNavBar()) {
            getWindow().setNavigationBarColor(CircleView.shiftColorDown(color));
        } else {
            getWindow().setNavigationBarColor(Color.BLACK);
        }
    }
}
 
Example #3
Source File: SelectableTextView.java    From AdvancedTextView with Apache License 2.0 6 votes vote down vote up
/**
 * 长按弹出菜单
 *
 * @param offsetY
 * @param actionMenu
 * @return 菜单创建成功,返回true
 */
private void showActionMenu(int offsetY, ActionMenu actionMenu) {

    mActionMenuPopupWindow = new PopupWindow(actionMenu, WindowManager.LayoutParams.WRAP_CONTENT,
            mActionMenuHeight, true);
    mActionMenuPopupWindow.setFocusable(true);
    mActionMenuPopupWindow.setOutsideTouchable(false);
    mActionMenuPopupWindow.setBackgroundDrawable(new ColorDrawable(0x00000000));
    mActionMenuPopupWindow.showAtLocation(this, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, offsetY);

    mActionMenuPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            Selection.removeSelection(getEditableText());
            // 如果设置了分散对齐,ActionMenu销毁后,强制刷新一次,防止出现文字背景未消失的情况
            if (isTextJustify)
                SelectableTextView.this.postInvalidate();
        }
    });
}
 
Example #4
Source File: CrossbowImageTest.java    From CrossBow with Apache License 2.0 6 votes vote down vote up
@Test
public void testErrorDefaultFade() {
    ColorDrawable defaultDrawable = new ColorDrawable(Color.BLUE);
    ColorDrawable errorDrawable = new ColorDrawable(Color.BLACK);

    CrossbowImage.Builder builder = new CrossbowImage.Builder(RuntimeEnvironment.application, null, null);
    builder.placeholder(defaultDrawable);
    builder.error(errorDrawable);
    builder.fade(200);
    CrossbowImage crossbowImage = builder.into(imageView).load();

    crossbowImage.setError(null);

    TransitionDrawable drawable = (TransitionDrawable) imageView.getDrawable();
    assertTrue(drawable.getNumberOfLayers() == 2);
}
 
Example #5
Source File: DropPopMenu.java    From zhangshangwuda with Apache License 2.0 6 votes vote down vote up
private void initList() {
	View popupWindow_view = LayoutInflater.from(context).inflate(
			R.layout.droppopmenu, null);
	popupWindow_view.setFocusableInTouchMode(true);
	// 设置popupWindow的布局
	popupWindow = new PopupWindow(popupWindow_view,
			WindowManager.LayoutParams.WRAP_CONTENT,
			WindowManager.LayoutParams.WRAP_CONTENT);
	popupWindow.setTouchable(true);
	popupWindow.setFocusable(true);
	// 这个是为了点击“返回Back”也能使其消失,并且并不会影响你的背景
	popupWindow.setBackgroundDrawable(new ColorDrawable(
			android.R.color.transparent));
	// 设置允许在外点击消失
	popupWindow.setOutsideTouchable(true);
	listView = (ListView) popupWindow_view
			.findViewById(R.id.droppopmenu_listView);
	popupWindow.update();
}
 
Example #6
Source File: DaVinci.java    From DaVinci with Apache License 2.0 6 votes vote down vote up
/**
 * Initialise DaVinci, muse have a googleApiClient to retrieve Bitmaps from Smartphone
 *
 * @param context the application context
 * @param size    the number of entry on the cache
 */
private DaVinci(Context context, int size) {

    Log.d(TAG, "====================================");

    this.mSize = size;
    this.mContext = context;
    this.mImagesCache = new LruCache<>(mSize);
    this.mDiskImageCache= new DiskLruImageCache(mContext, TAG, cacheSize, Bitmap.CompressFormat.PNG, 100);

    this.mPlaceHolder = new ColorDrawable(Color.TRANSPARENT);

    mApiClient = new GoogleApiClient.Builder(context)
            .addApi(Wearable.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

    mApiClient.connect();
    //TODO disconnect when the application close
}
 
Example #7
Source File: Util.java    From QuranyApp with Apache License 2.0 6 votes vote down vote up
public static Dialog getDialog(Context context, String message, String title) {
    View view = LayoutInflater.from(context).inflate(R.layout.custome_dialoge_title, null);
    TextView titleTextView = view.findViewById(R.id.tvInfo);
    titleTextView.setText(title);

    TextView textView = view.findViewById(R.id.tvDialogeText);
    textView.setText(message);

    Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(view);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    return dialog;

}
 
Example #8
Source File: EditFragment.java    From EasyPhotos with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    Window dialogWindow = getDialog().getWindow();
    if (null != dialogWindow) {
        WindowManager.LayoutParams attrs = dialogWindow.getAttributes();
        attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
        dialogWindow.setAttributes(attrs);
        dialogWindow.requestFeature(Window.FEATURE_NO_TITLE);
    }

    super.onActivityCreated(savedInstanceState);

    if (null != dialogWindow) {
        dialogWindow.setBackgroundDrawable(new ColorDrawable(0x00000000));
        dialogWindow.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
        dialogWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    }
}
 
Example #9
Source File: CustomTabToolbar.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    setBackground(new ColorDrawable(
            ApiCompatibilityUtils.getColor(getResources(), R.color.default_primary_color)));
    mUrlBar = (UrlBar) findViewById(R.id.url_bar);
    mUrlBar.setHint("");
    mUrlBar.setDelegate(this);
    mUrlBar.setEnabled(false);
    mUrlBar.setAllowFocus(false);
    mTitleBar = (TextView) findViewById(R.id.title_bar);
    mLocationBarFrameLayout = findViewById(R.id.location_bar_frame_layout);
    mTitleUrlContainer = findViewById(R.id.title_url_container);
    mTitleUrlContainer.setOnLongClickListener(this);
    mSecurityButton = (TintedImageButton) findViewById(R.id.security_button);
    mSecurityIconType = ConnectionSecurityLevel.NONE;
    mCustomActionButton = (ImageButton) findViewById(R.id.action_button);
    mCustomActionButton.setOnLongClickListener(this);
    mCloseButton = (ImageButton) findViewById(R.id.close_button);
    mCloseButton.setOnLongClickListener(this);
    mAnimDelegate = new CustomTabToolbarAnimationDelegate(mSecurityButton, mTitleUrlContainer);
}
 
Example #10
Source File: RequestSendtoAdmin.java    From XERUNG with Apache License 2.0 6 votes vote down vote up
public RequestSendtoAdmin(Context context, int id, String number,String name, String request, Object dashBoardActivity) {
	super(context);
	// TODO Auto-generated constructor stub
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	setContentView(R.layout.dialog_send_request_admin);
	getWindow().setBackgroundDrawable(new ColorDrawable(android.R.color.transparent));
	setCancelable(false);
	this.context = context;
	roboto = Typeface.createFromAsset(context.getAssets(),"font/Roboto-Regular.ttf");
	activity = (Activity) context;
	this.requestSend= request;
	this.groupName= name;
	this.groupNumber= number;
	this.gUID= id;
	dashBoardActObjecct = dashBoardActivity;
	shared = new SharedPreferanceData(context);
	requestDilog = this;
	comman = new Comman();
	
}
 
Example #11
Source File: BaseLibraryActivityViewModel.java    From Jockey with Apache License 2.0 6 votes vote down vote up
public BaseLibraryActivityViewModel(Context context, boolean fitSystemWindows) {
    super(context);

    mFitSystemWindows = fitSystemWindows;
    mExpandedHeight = getDimensionPixelSize(R.dimen.miniplayer_height);
    mAnimateSlideInOut = false;

    mMiniplayerHeight = new ObservableInt(0);
    mMiniplayerAlpha = new ObservableFloat(1.0f);
    mNowPlayingToolbarAlpha = new ObservableFloat(0.0f);

    int backgroundColor = getColor(R.color.background);
    mNowPlayingBackground = new ColorDrawable(backgroundColor);

    setPlaybackOngoing(false);

    mMiniplayerHeight.addOnPropertyChangedCallback(new OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(androidx.databinding.Observable sender, int propertyId) {
            notifyPropertyChanged(BR.miniplayerShadowAlpha);
        }
    });
}
 
Example #12
Source File: EditServiceAdapter.java    From Android-Application-ZJB with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(EditServiceViewHolder holder, int position) {
    GridLayoutManager.LayoutParams params = new GridLayoutManager.LayoutParams(mItemSize, mItemSize);
    holder.itemView.setLayoutParams(params);
    holder.mEditImageView.setImageResource(editBtnResId);
    holder.mEditImageView.setVisibility(isEditStatus ? View.VISIBLE : View.INVISIBLE);

    Services service = mData.get(position);
    ZjbImageLoader.create(service.getIcon())
            .setBitmapConfig(Bitmap.Config.ARGB_8888)
            .setDisplayType(ZjbImageLoader.DISPLAY_DEFAULT)
            .setDefaultDrawable(new ColorDrawable(0xffe0dedc))
            .into(holder.mImageView);
    holder.itemView.setOnClickListener(v -> {
        if (null != mListener && isEditStatus) {
            mListener.onItemClick(service, holder.getAdapterPosition());
        }
    });
}
 
Example #13
Source File: CommentListDialog.java    From xposed-aweme with Apache License 2.0 6 votes vote down vote up
/**
 * 创建左滑菜单
 */
private SwipeMenuCreator newMenuCreator() {

    return new SwipeMenuCreator() {

        @Override
        public void create(SwipeMenu menu) {

            SwipeMenuItem deleteItem = new SwipeMenuItem(getContext());

            deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9, 0x3F, 0x25)));
            deleteItem.setWidth(DisplayUtil.dip2px(getContext(), 80f));
            deleteItem.setTitle("删除");
            deleteItem.setTitleSize(14);
            deleteItem.setTitleColor(Color.WHITE);

            menu.addMenuItem(deleteItem);
        }
    };
}
 
Example #14
Source File: ImageWorker.java    From android-DisplayingBitmaps with Apache License 2.0 6 votes vote down vote up
/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td =
                new TransitionDrawable(new Drawable[] {
                        new ColorDrawable(android.R.color.transparent),
                        drawable
                });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(
                new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}
 
Example #15
Source File: InputWindow.java    From Chimee with MIT License 5 votes vote down vote up
private void colorBackground(Canvas canvas) {
    int color = DEFAULT_BACKGROUND_COLOR;
    Drawable background = getBackground();
    if (background instanceof ColorDrawable)
        color = ((ColorDrawable) background).getColor();
    Paint paint = new Paint();
    paint.setColor(color);
    paint.setStyle(Paint.Style.FILL);
    canvas.drawPaint(paint);
}
 
Example #16
Source File: BgColorLinearLayout.java    From particle-android with Apache License 2.0 5 votes vote down vote up
public int getBackgroundColor() {
    Drawable d = getBackground();
    if (d == null || !(d instanceof ColorDrawable)) {
        return 0x00000000;
    } else {
        return ((ColorDrawable) getBackground()).getColor();
    }
}
 
Example #17
Source File: LoadApkFragment.java    From BuildmLearn-Toolkit-Android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @brief Changes the color scheme when switching from normal mode to edit mode.
 * <p/>
 * Edit mode is triggered, when the list item is long pressed.
 */
private void changeColorScheme() {
    int primaryColor = ContextCompat.getColor(getActivity(), R.color.color_primary_dark);
    int primaryColorDark = ContextCompat.getColor(getActivity(), R.color.color_selected_dark);
    ((AppCompatActivity) activity).getSupportActionBar().setBackgroundDrawable(new ColorDrawable(primaryColor));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().setStatusBarColor(primaryColorDark);
        activity.getWindow().setNavigationBarColor(primaryColor);
    }

    showTemplateSelectedMenu = true;
    activity.invalidateOptionsMenu();
}
 
Example #18
Source File: LatestFragment.java    From wallpaper with GNU General Public License v2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	View view = inflater.inflate(R.layout.fragment_latest, container, false);

	mPullToRefreshView = (PullToRefreshView) view.findViewById(R.id.fragment_pull_latest_view);
	MainActivity activity = (MainActivity) this.getActivity();
	mPullToRefreshView.setOnHeaderRefreshListener(activity);
	mPullToRefreshView.setOnFooterRefreshListener(activity);

	latestNetWorkRelativeLayout = (RelativeLayout) view.findViewById(R.id.latest_netWork_relativeLayout);
	
	latestGridView = (GridView) view.findViewById(R.id.fragment_latest_gridview);
	latestGridView.setSelector(new ColorDrawable(Color.TRANSPARENT));

	float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0);
	latestGridView.setColumnWidth((int) width);

	latestGridView.setOnItemClickListener(this);
	
	if(this.mShowNoNetworkView){
		latestNetWorkRelativeLayout.setVisibility(View.VISIBLE);
		mPullToRefreshView.setVisibility(View.GONE);
	}else{
		latestNetWorkRelativeLayout.setVisibility(View.GONE);
		mPullToRefreshView.setVisibility(View.VISIBLE);
	}
	
	return view;
}
 
Example #19
Source File: FloatingWindowsViewHolder.java    From FastAccess with GNU General Public License v3.0 5 votes vote down vote up
public void onSetupBackground() {
    int bgColor = PrefHelper.getInt(PrefConstant.FA_BACKGROUND);
    int bgAlpha = PrefHelper.getInt(PrefConstant.FA_BACKGROUND_ALPHA);
    Drawable drawable = new ColorDrawable(bgColor == 0 ? Color.TRANSPARENT : bgColor);
    drawable.setAlpha(bgAlpha == 0 ? 255 : bgAlpha);
    tabBar.setBackground(drawable);
}
 
Example #20
Source File: DebugOverlay.java    From Carbon with Apache License 2.0 5 votes vote down vote up
public void show() {
    View anchor = context.getWindow().getDecorView().getRootView();
    setContentView(new DebugLayout(context, anchor));
    getContentView().setLayoutParams(new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    setBackgroundDrawable(new ColorDrawable(context.getResources().getColor(android.R.color.transparent)));
    setTouchable(false);
    setFocusable(false);
    setOutsideTouchable(false);
    setAnimationStyle(0);
    super.showAtLocation(anchor, Gravity.START | Gravity.TOP, 0, 0);
    update(anchor.getWidth(), anchor.getHeight());
    anchor.getViewTreeObserver().addOnPreDrawListener(listener);
}
 
Example #21
Source File: PagerTabStripInterceptor.java    From holoaccent with Apache License 2.0 5 votes vote down vote up
@Override
public Drawable getDrawable(Resources res, AccentPalette palette, int resId) {
	if (resId == R.drawable.ha__pager_tab_strip_background_reference)
		return new ColorDrawable(palette.getDarkAccentColor(DEFAULT_ALPHA));
	if (resId == R.drawable.ha__pager_tab_strip_background_light_reference)
		return new ColorDrawable(palette.getDarkAccentColor(LIGHT_ALPHA));
	return null;
}
 
Example #22
Source File: StyleBuilderImpl.java    From Markdown with MIT License 5 votes vote down vote up
@Override
public SpannableStringBuilder gap() {
    SpannableStringBuilder builder = new SpannableStringBuilder("$");
    Drawable underLine = new ColorDrawable(h_under_line_color);
    UnderLineSpan underLineSpan = new UnderLineSpan(underLine, getTextViewRealWidth(), 10);
    builder.setSpan(underLineSpan, 0, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return builder;
}
 
Example #23
Source File: CommonUtils.java    From InstantAppStarter with MIT License 5 votes vote down vote up
public static ProgressDialog showLoadingDialog(Context context) {
    ProgressDialog progressDialog = new ProgressDialog(context);
    progressDialog.show();
    if (progressDialog.getWindow() != null) {
        progressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    }
    progressDialog.setContentView(R.layout.progress_dialog);
    progressDialog.setIndeterminate(true);
    progressDialog.setCancelable(true);
    progressDialog.setCanceledOnTouchOutside(false);
    return progressDialog;
}
 
Example #24
Source File: FloatingActionButton.java    From android_gisapp with GNU General Public License v3.0 5 votes vote down vote up
private Drawable createInnerStrokesDrawable(
        final int color,
        float strokeWidth)
{
    if (!mStrokeVisible) {
        return new ColorDrawable(Color.TRANSPARENT);
    }

    ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());

    final int bottomStrokeColor = darkenColor(color);
    final int bottomStrokeColorHalfTransparent = halfTransparent(bottomStrokeColor);
    final int topStrokeColor = lightenColor(color);
    final int topStrokeColorHalfTransparent = halfTransparent(topStrokeColor);

    final Paint paint = shapeDrawable.getPaint();
    paint.setAntiAlias(true);
    paint.setStrokeWidth(strokeWidth);
    paint.setStyle(Style.STROKE);
    shapeDrawable.setShaderFactory(
            new ShaderFactory()
            {
                @Override
                public Shader resize(
                        int width,
                        int height)
                {
                    return new LinearGradient(
                            width / 2, 0, width / 2, height, new int[] {
                            topStrokeColor,
                            topStrokeColorHalfTransparent,
                            color,
                            bottomStrokeColorHalfTransparent,
                            bottomStrokeColor}, new float[] {0f, 0.2f, 0.5f, 0.8f, 1f},
                            TileMode.CLAMP);
                }
            });

    return shapeDrawable;
}
 
Example #25
Source File: BirdActivity.java    From Moring-Alarm with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	int pos = 0;
	if (getIntent().getExtras() != null) {
		pos = getIntent().getExtras().getInt("pos");
	}
	
	String[] birds = getResources().getStringArray(R.array.birds);
	TypedArray imgs = getResources().obtainTypedArray(R.array.birds_img);
	int resId = imgs.getResourceId(pos, -1);
	
	setTitle(birds[pos]);
	getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
	ColorDrawable color = new ColorDrawable(Color.BLACK);
	color.setAlpha(128);
	getSupportActionBar().setBackgroundDrawable(color);
	getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	mHandler = new Handler();
	
	ImageView imageView = new ImageView(this);
	imageView.setScaleType(ScaleType.CENTER_INSIDE);
	imageView.setImageResource(resId);
	imageView.setOnClickListener(new OnClickListener() {
		public void onClick(View v) {
			getSupportActionBar().show();
			hideActionBarDelayed(mHandler);
		}
	});
	setContentView(imageView);
	this.getWindow().setBackgroundDrawableResource(android.R.color.black);
}
 
Example #26
Source File: AboutFragment.java    From Linphone4Android with GNU General Public License v3.0 5 votes vote down vote up
private void displayUploadLogsInProgress() {
	if (uploadInProgress) {
		return;
	}
	uploadInProgress = true;
	
	progress = ProgressDialog.show(LinphoneActivity.instance(), null, null);
	Drawable d = new ColorDrawable(ContextCompat.getColor(getActivity(), R.color.colorE));
	d.setAlpha(200);
	progress.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
	progress.getWindow().setBackgroundDrawable(d);
	progress.setContentView(R.layout.progress_dialog);
	progress.show();
}
 
Example #27
Source File: MainActivity.java    From drawee-text-view with Apache License 2.0 5 votes vote down vote up
CharSequence buildText2() {
    SpannableStringBuilder builder = new SpannableStringBuilder();
    builder.append("Reset text in same DraweeTextView~~~~");
    int start = builder.length();
    builder.append("[img]");
    builder.setSpan(new DraweeSpan.Builder("http://img.yo9.com/24fe1ed09fbc11e59d8700163e00043c")
                    .setLayout(50, 50).build(),
            start, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    builder.append("\n\n");
    builder.append("This is a gif, margin=10:");
    start = builder.length();
    builder.append("[gif:d559f520246811e69a4a00163e000cdb]");
    Drawable placeHolder = new ColorDrawable(Color.BLUE);
    builder.setSpan(new DraweeSpan.Builder("http://img.yo9.com/d559f520246811e69a4a00163e000cdb")
                    .setPlaceHolderImage(placeHolder)
                    .setLayout(200, 197)
                    .setMargin(10)
                    .setShowAnimaImmediately(true)
                    .build(),
            start, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    builder.append("\n\n");
    start = builder.length();
    builder.append("[emotion:tv_cheers]");
    builder.setSpan(new DraweeSpan.Builder("http://static.yo9.com/web/emotions/tv_cheers.png").build()
            , start, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    builder.append("bilibili- ( ゜- ゜)つロ 乾杯~\n");
    return builder;
}
 
Example #28
Source File: UIHelper.java    From uPods-android with Apache License 2.0 5 votes vote down vote up
private static StateListDrawable getStateListDrawable(
        int normalColor, int pressedColor) {
    StateListDrawable states = new StateListDrawable();
    states.addState(new int[]{android.R.attr.state_pressed},
            new ColorDrawable(pressedColor));
    states.addState(new int[]{android.R.attr.state_focused},
            new ColorDrawable(pressedColor));
    states.addState(new int[]{android.R.attr.state_activated},
            new ColorDrawable(pressedColor));
    states.addState(new int[]{},
            new ColorDrawable(normalColor));
    return states;
}
 
Example #29
Source File: MainActivity.java    From android-ui-toolkit-demos with Apache License 2.0 5 votes vote down vote up
@NonNull
private ItemHolderInfo getItemHolderInfo(MyViewHolder viewHolder, ColorTextInfo info) {
    final MyViewHolder myHolder = viewHolder;
    final int bgColor = ((ColorDrawable) myHolder.container.getBackground()).getColor();
    info.color = bgColor;
    info.text = (String) myHolder.textView.getText();
    return info;
}
 
Example #30
Source File: BaseRecyclerViewScrubber.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
private void init(Context context) {
    mIsRtl = Utilities.isRtl(context.getResources());
    LayoutInflater.from(context).inflate(R.layout.scrub_layout, this);
    mTransparentDrawable = new ColorDrawable(Color.TRANSPARENT);
    mScrubberAnimationState = new ScrubberAnimationState();
    mSeekBar = (SeekBar) findViewById(R.id.scrubber);
    mScrubberText = (AutoExpandTextView) findViewById(R.id.scrubberText);
    mSeekBar.setOnSeekBarChangeListener(mScrubberAnimationState);
}