List of usage examples for android.graphics.drawable GradientDrawable GradientDrawable
private GradientDrawable(@NonNull GradientState state, @Nullable Resources res)
From source file:com.yahala.ui.Views.EmojiView.java
private void init() { setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < Emoji.data.length; i++) { GridView gridView = new GridView(getContext()); gridView.setColumnWidth(OSUtilities.dpf(45.0f)); gridView.setNumColumns(-1);/*from ww w .j a v a 2 s .co m*/ views.add(gridView); EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]); gridView.setAdapter(localEmojiGridAdapter); adapters.add(localEmojiGridAdapter); } setBackgroundDrawable( new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { -14145496, -16777216 })); pager = new ViewPager(getContext()); pager.setAdapter(new EmojiPagesAdapter()); PagerSlidingTabStripEmoji tabs = new PagerSlidingTabStripEmoji(getContext()); tabs.setViewPager(pager); tabs.setShouldExpand(true); tabs.setIndicatorColor(0xff33b5e5); tabs.setIndicatorHeight(OSUtilities.dpf(2.0f)); tabs.setUnderlineHeight(OSUtilities.dpf(2.0f)); tabs.setUnderlineColor(1711276032); tabs.setTabBackground(0); LinearLayout localLinearLayout = new LinearLayout(getContext()); localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); localLinearLayout.addView(tabs, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); ImageView localImageView = new ImageView(getContext()); localImageView.setImageResource(R.drawable.ic_emoji_backspace); localImageView.setScaleType(ImageView.ScaleType.CENTER_CROP); localImageView.setBackgroundResource(R.drawable.bg_emoji_bs); localImageView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (EmojiView.this.listener != null) { EmojiView.this.listener.onBackspace(); } } }); localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(OSUtilities.dpf(61.0f), LayoutParams.MATCH_PARENT)); recentsWrap = new FrameLayout(getContext()); recentsWrap.addView(views.get(0)); TextView localTextView = new TextView(getContext()); localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); localTextView.setTextSize(18.0f); localTextView.setTextColor(-7829368); localTextView.setGravity(17); recentsWrap.addView(localTextView); views.get(0).setEmptyView(localTextView); addView(localLinearLayout, new LinearLayout.LayoutParams(-1, OSUtilities.dpf(48.0f))); addView(pager); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } }
From source file:org.mareatlantica.ui.Views.EmojiView.java
private void init() { setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < Emoji.data.length; i++) { GridView gridView = new GridView(getContext()); gridView.setColumnWidth(AndroidUtilities.dpf(45.0f)); gridView.setNumColumns(-1);/*www . j a v a 2 s . c om*/ views.add(gridView); EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]); gridView.setAdapter(localEmojiGridAdapter); adapters.add(localEmojiGridAdapter); } setBackgroundDrawable( new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { -14145496, -16777216 })); pager = new ViewPager(getContext()); pager.setAdapter(new EmojiPagesAdapter()); PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(getContext()); tabs.setViewPager(pager); tabs.setShouldExpand(true); tabs.setIndicatorColor(0xff33b5e5); tabs.setIndicatorHeight(AndroidUtilities.dpf(2.0f)); tabs.setUnderlineHeight(AndroidUtilities.dpf(2.0f)); tabs.setUnderlineColor(1711276032); tabs.setTabBackground(0); LinearLayout localLinearLayout = new LinearLayout(getContext()); localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); localLinearLayout.addView(tabs, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); ImageView localImageView = new ImageView(getContext()); localImageView.setImageResource(R.drawable.ic_emoji_backspace); localImageView.setScaleType(ImageView.ScaleType.CENTER); localImageView.setBackgroundResource(R.drawable.bg_emoji_bs); localImageView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (EmojiView.this.listener != null) { EmojiView.this.listener.onBackspace(); } } }); localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(AndroidUtilities.dpf(61.0f), LayoutParams.MATCH_PARENT)); recentsWrap = new FrameLayout(getContext()); recentsWrap.addView(views.get(0)); TextView localTextView = new TextView(getContext()); localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); localTextView.setTextSize(18.0f); localTextView.setTextColor(-7829368); localTextView.setGravity(17); recentsWrap.addView(localTextView); views.get(0).setEmptyView(localTextView); addView(localLinearLayout, new LinearLayout.LayoutParams(-1, AndroidUtilities.dpf(48.0f))); addView(pager); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } }
From source file:hoahong.facebook.messenger.ui.EmojiView.java
private void init() { setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < Emoji.data.length; i++) { GridView gridView = new GridView(getContext()); if (Utils.isTablet()) { gridView.setColumnWidth(Utils.dp(60)); } else {// w ww. j a v a 2s. c om gridView.setColumnWidth(Utils.dp(45)); } gridView.setNumColumns(-1); views.add(gridView); EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]); gridView.setAdapter(localEmojiGridAdapter); adapters.add(localEmojiGridAdapter); } setBackgroundDrawable( new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { -14145496, -16777216 })); pager = new ViewPager(getContext()); pager.setAdapter(new EmojiPagesAdapter()); PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(getContext()); tabs.setViewPager(pager); tabs.setShouldExpand(true); tabs.setIndicatorColor(0xff33b5e5); tabs.setIndicatorHeight(Utils.dpf(2.0f)); tabs.setUnderlineHeight(Utils.dpf(2.0f)); tabs.setUnderlineColor(0x66000000); tabs.setTabBackground(0); LinearLayout localLinearLayout = new LinearLayout(getContext()); localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); localLinearLayout.addView(tabs, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); ImageView localImageView = new ImageView(getContext()); localImageView.setImageResource(R.drawable.ic_emoji_backspace); localImageView.setScaleType(ImageView.ScaleType.CENTER); localImageView.setBackgroundResource(R.drawable.bg_emoji_bs); localImageView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (EmojiView.this.listener != null) { EmojiView.this.listener.onBackspace(); } } }); localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(Utils.dp(61), LayoutParams.MATCH_PARENT)); recentsWrap = new FrameLayout(getContext()); recentsWrap.addView(views.get(0)); TextView localTextView = new TextView(getContext()); localTextView.setText("No recent"); localTextView.setTextSize(18.0f); localTextView.setTextColor(-7829368); localTextView.setGravity(17); recentsWrap.addView(localTextView); views.get(0).setEmptyView(localTextView); addView(localLinearLayout, new LinearLayout.LayoutParams(-1, Utils.dpf(48.0f))); addView(pager); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } }
From source file:org.telegram.ui.Views.EmojiView.java
private void init() { setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < Emoji.data.length; i++) { GridView gridView = new GridView(getContext()); if (AndroidUtilities.isTablet()) { gridView.setColumnWidth(AndroidUtilities.dp(60)); } else {/*from ww w . j a va 2s . c o m*/ gridView.setColumnWidth(AndroidUtilities.dp(45)); } gridView.setNumColumns(-1); views.add(gridView); EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]); gridView.setAdapter(localEmojiGridAdapter); adapters.add(localEmojiGridAdapter); } setBackgroundDrawable( new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { -14145496, -16777216 })); pager = new ViewPager(getContext()); pager.setAdapter(new EmojiPagesAdapter()); PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(getContext()); tabs.setViewPager(pager); tabs.setShouldExpand(true); tabs.setIndicatorColor(0xff33b5e5); tabs.setIndicatorHeight(AndroidUtilities.dpf(2.0f)); tabs.setUnderlineHeight(AndroidUtilities.dpf(2.0f)); tabs.setUnderlineColor(0x66000000); tabs.setTabBackground(0); LinearLayout localLinearLayout = new LinearLayout(getContext()); localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); localLinearLayout.addView(tabs, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); ImageView localImageView = new ImageView(getContext()); localImageView.setImageResource(R.drawable.ic_emoji_backspace); localImageView.setScaleType(ImageView.ScaleType.CENTER); localImageView.setBackgroundResource(R.drawable.bg_emoji_bs); localImageView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (EmojiView.this.listener != null) { EmojiView.this.listener.onBackspace(); } } }); localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(AndroidUtilities.dp(61), LayoutParams.MATCH_PARENT)); recentsWrap = new FrameLayout(getContext()); recentsWrap.addView(views.get(0)); TextView localTextView = new TextView(getContext()); localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); localTextView.setTextSize(18.0f); localTextView.setTextColor(-7829368); localTextView.setGravity(17); recentsWrap.addView(localTextView); views.get(0).setEmptyView(localTextView); addView(localLinearLayout, new LinearLayout.LayoutParams(-1, AndroidUtilities.dpf(48.0f))); addView(pager); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } }
From source file:com.miz.mizuu.fragments.ShowDetailsFragment.java
public void onViewCreated(final View v, Bundle savedInstanceState) { super.onViewCreated(v, savedInstanceState); if (MizLib.isPortrait(getActivity())) { mActionBarBackgroundDrawable = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, new int[] { 0x00000000, 0xaa000000 }); getActivity().getActionBar().setBackgroundDrawable(mActionBarBackgroundDrawable); ObservableScrollView sv = (ObservableScrollView) v.findViewById(R.id.scrollView1); sv.setOnScrollChangedListener(new OnScrollChangedListener() { @Override/*from w w w. j a v a2 s.co m*/ public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { final int headerHeight = v.findViewById(R.id.imageBackground).getHeight() - getActivity().getActionBar().getHeight(); final float ratio = (float) Math.min(Math.max(t, 0), headerHeight) / headerHeight; final int newAlpha = (int) (ratio * 255); mActionBarBackgroundDrawable = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, new int[] { Color.parseColor("#" + ((Integer.toHexString(newAlpha).length() == 1) ? ("0" + Integer.toHexString(newAlpha)) : Integer.toHexString(newAlpha)) + "080808"), (newAlpha >= 170) ? Color.parseColor("#" + Integer.toHexString(newAlpha) + "080808") : 0xaa080808 }); getActivity().getActionBar().setBackgroundDrawable(mActionBarBackgroundDrawable); } }); } background = (ImageView) v.findViewById(R.id.imageBackground); textTitle = (TextView) v.findViewById(R.id.movieTitle); textPlot = (TextView) v.findViewById(R.id.textView2); textGenre = (TextView) v.findViewById(R.id.textView7); textRuntime = (TextView) v.findViewById(R.id.textView9); textReleaseDate = (TextView) v.findViewById(R.id.textReleaseDate); textRating = (TextView) v.findViewById(R.id.textView12); textTagline = (TextView) v.findViewById(R.id.textView6); textCertification = (TextView) v.findViewById(R.id.textView11); cover = (ImageView) v.findViewById(R.id.traktIcon); // Set the show title textTitle.setVisibility(View.VISIBLE); textTitle.setText(thisShow.getTitle()); textTitle.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "RobotoCondensed-Regular.ttf")); textTitle.setLayerType(View.LAYER_TYPE_SOFTWARE, null); textPlot.setTypeface(mLight); textGenre.setTypeface(mLight); textRuntime.setTypeface(mLight); textReleaseDate.setTypeface(mLight); textRating.setTypeface(mLight); textCertification.setTypeface(mLight); // Set the show plot textPlot.setText(thisShow.getDescription()); textTagline.setVisibility(TextView.GONE); // Set the show genre if (!MizLib.isEmpty(thisShow.getGenres())) { textGenre.setText(thisShow.getGenres()); } else { textGenre.setText(R.string.stringNA); } // Set the show runtime textRuntime.setText(MizLib.getPrettyTime(getActivity(), Integer.parseInt(thisShow.getRuntime()))); // Set the first aired date textReleaseDate.setText(MizLib.getPrettyDate(getActivity(), thisShow.getFirstAirdate())); // Set the show rating if (!thisShow.getRating().equals("0.0/10")) { if (thisShow.getRating().contains("/")) { try { int rating = (int) (Double.parseDouble( thisShow.getRating().substring(0, thisShow.getRating().indexOf("/"))) * 10); textRating.setText(Html.fromHtml(rating + "<small> %</small>")); } catch (NumberFormatException e) { textRating.setText(Html.fromHtml(thisShow.getRating().replace("/", "<small> / ") + "</small>")); } } else { textRating.setText(thisShow.getRating()); } } else { textRating.setText(R.string.stringNA); } // Set the show certification if (!MizLib.isEmpty(thisShow.getCertification())) { textCertification.setText(thisShow.getCertification()); } else { textCertification.setText(R.string.stringNA); } loadImages(); }
From source file:com.aretha.slidemenu.SlideMenu.java
public SlideMenu(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // we want to draw drop shadow of content mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mVelocityTracker = VelocityTracker.obtain(); mScroller = new Scroller(context, mInterpolator); mContentHitRect = new Rect(); STATUS_BAR_HEIGHT = (int) getStatusBarHeight(context); setWillNotDraw(false);/*from ww w. ja v a2 s .co m*/ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SlideMenu, defStyle, 0); // Set the shadow attributes setPrimaryShadowWidth(a.getDimension(R.styleable.SlideMenu_primaryShadowWidth, 30)); setSecondaryShadowWidth(a.getDimension(R.styleable.SlideMenu_secondaryShadowWidth, 30)); Drawable primaryShadowDrawable = a.getDrawable(R.styleable.SlideMenu_primaryShadowDrawable); if (null == primaryShadowDrawable) { primaryShadowDrawable = new GradientDrawable(Orientation.LEFT_RIGHT, new int[] { Color.TRANSPARENT, Color.argb(99, 0, 0, 0) }); } setPrimaryShadowDrawable(primaryShadowDrawable); Drawable secondaryShadowDrawable = a.getDrawable(R.styleable.SlideMenu_primaryShadowDrawable); if (null == secondaryShadowDrawable) { secondaryShadowDrawable = new GradientDrawable(Orientation.LEFT_RIGHT, new int[] { Color.argb(99, 0, 0, 0), Color.TRANSPARENT }); } setSecondaryShadowDrawable(secondaryShadowDrawable); mSlideDirectionFlag = a.getInt(R.styleable.SlideMenu_slideDirection, FLAG_DIRECTION_LEFT | FLAG_DIRECTION_RIGHT); setFocusable(true); setFocusableInTouchMode(true); a.recycle(); }
From source file:com.base.view.slidemenu.SlideMenu.java
public SlideMenu(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // we want to draw drop shadow of content mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mVelocityTracker = VelocityTracker.obtain(); mContentHitRect = new Rect(); mEdgeSlideDetectRect = new Rect(); STATUS_BAR_HEIGHT = (int) getStatusBarHeight(context); setWillNotDraw(false);// w ww . jav a 2 s.c o m TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SlideMenu, defStyle, 0); // Set the shadow attributes setPrimaryShadowWidth(a.getDimension(R.styleable.SlideMenu_primaryShadowWidth, 30)); setSecondaryShadowWidth(a.getDimension(R.styleable.SlideMenu_secondaryShadowWidth, 30)); Drawable primaryShadowDrawable = a.getDrawable(R.styleable.SlideMenu_primaryShadowDrawable); if (null == primaryShadowDrawable) { primaryShadowDrawable = new GradientDrawable(Orientation.LEFT_RIGHT, new int[] { Color.TRANSPARENT, Color.argb(99, 0, 0, 0) }); } setPrimaryShadowDrawable(primaryShadowDrawable); Drawable secondaryShadowDrawable = a.getDrawable(R.styleable.SlideMenu_secondaryShadowDrawable); if (null == secondaryShadowDrawable) { secondaryShadowDrawable = new GradientDrawable(Orientation.LEFT_RIGHT, new int[] { Color.argb(99, 0, 0, 0), Color.TRANSPARENT }); } setSecondaryShadowDrawable(secondaryShadowDrawable); int interpolatorResId = a.getResourceId(R.styleable.SlideMenu_interpolator, -1); setInterpolator(-1 == interpolatorResId ? DEFAULT_INTERPOLATOR : AnimationUtils.loadInterpolator(context, interpolatorResId)); mSlideDirectionFlag = a.getInt(R.styleable.SlideMenu_slideDirection, FLAG_DIRECTION_LEFT | FLAG_DIRECTION_RIGHT); setEdgeSlideEnable(a.getBoolean(R.styleable.SlideMenu_edgeSlide, false)); setEdgetSlideWidth(a.getDimensionPixelSize(R.styleable.SlideMenu_edgeSlideWidth, 100)); a.recycle(); setFocusable(true); setFocusableInTouchMode(true); }
From source file:com.dm.xz.views.PinnedSectionListView.java
public void initShadow(boolean visible) { if (visible) { if (mShadowDrawable == null) { mShadowDrawable = new GradientDrawable(Orientation.TOP_BOTTOM, new int[] { Color.parseColor("#ffa0a0a0"), Color.parseColor("#50a0a0a0"), Color.parseColor("#00a0a0a0") }); mShadowHeight = (int) (8 * getResources().getDisplayMetrics().density); }/* ww w. j ava 2s. com*/ } else { if (mShadowDrawable != null) { mShadowDrawable = null; mShadowHeight = 0; } } }
From source file:io.imoji.sdk.grid.ui.ResultView.java
private Drawable getPlaceholder(int placeholderRandomizer, int position) { int[] colorArray = context.getResources().getIntArray(R.array.search_widget_placeholder_colors); int color = colorArray[(placeholderRandomizer + position) % colorArray.length]; GradientDrawable placeholder = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { ColorUtils.setAlphaComponent(Color.WHITE, GRADIENT_START_ALPHA), ColorUtils.setAlphaComponent(Color.WHITE, GRADIENT_END_ALPHA) }); placeholder.setColor(color);/* www . j a v a 2 s . c o m*/ placeholder.setShape(GradientDrawable.OVAL); return placeholder; }
From source file:com.redwoodsystems.android.apps.LightingListFragment.java
private void setupScenesList() { Log.d(TAG, "setupScenesList called"); ListView listView = (ListView) getActivity().findViewById(android.R.id.list); TextView dummy = new TextView(getActivity()); ImageView dummy2 = new ImageView(getActivity()); listView.addFooterView(dummy, null, true); listView.setFooterDividersEnabled(true); listView.addHeaderView(dummy2, null, true); listView.setHeaderDividersEnabled(true); int[] colors = { 0, 0xFFF47836, 0 }; // Pantone172 for the example listView.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors)); listView.setDividerHeight(1);/* ww w . j a v a 2 s .c o m*/ //TODO: set Empty Text inside View //setEmptyText("No Scenes found"); mSceneAdapter = new SceneAdapter(getActivity(), R.layout.scene_item_layout, R.id.sceneText); setListAdapter(mSceneAdapter); Uri dummyUri = null; Bundle params = new Bundle(); Bundle args = new Bundle(); args.putParcelable(ARGS_URI, dummyUri); args.putParcelable(ARGS_PARAMS, params); // Initialize the Loader. Log.d(TAG, "calling initLoader.."); getActivity().getSupportLoaderManager().initLoader(LOADER_SCENES, null, this); }