Search Results

Search found 3 results on 1 pages for 'gradientdrawable'.

Page 1/1 | 1 

  • How to use Android GradientDrawable

    - by Janusz
    I try to use the GradientDrawable to set a gradient to some backgrounds and buttons. Sadly the documentation is not very detailed. What are the main attributes to configure the gradient? I understand start and endcolor but some of the other attributes could need some explanation. At the moment I used images as the background for the buttons but a drawable defined in XML would be much nicer. I try to get a look like this (It is a very light gradient):

    Read the article

  • How to draw a smooth/dithered gradient on a canvas in Android

    - by André
    Several answers mention to use GradientDrawable.setDither(true) to draw smooth gradients in Android. That has no effect in my code. Any idea what I have to change to get a well looking gradient in my live wallpaper? GradientDrawable gradient = new GradientDrawable(Orientation.TL_BR, colors); gradient.setGradientType(GradientDrawable.RADIAL_GRADIENT); gradient.setGradientRadius(canvas.getWidth() * 2); gradient.setDither(true);g gradient.setGradientCenter(-0.1f, -0.1f); gradient.setBounds(cb); gradient.draw(canvas);

    Read the article

  • Unable to add separator in list view

    - by Suru
    This is my code @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.email_list_main); emailResults = new ArrayList<GetEmailFromDatabase>(); //int[] colors = {0,0xFFFF0000,0}; //getListView().setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors)); //getListView().setDividerHeight(2); emailListFeedAdapter = new EmailListFeedAdapter(this, R.layout.email_listview_row, emailResults); setListAdapter(this.emailListFeedAdapter); getResults(); if(emailResults != null && emailResults.size() > -1){ emailListFeedAdapter.notifyDataSetChanged(); for(int i=0;i< emailResults.size();i++){ try { Here I getting email Sent date emailListFeedAdapter.add( emailResults.get(i)); datetime_text1 = emailResults.get(i).getDate(); formatter1 = new SimpleDateFormat(); formatter1 = DateFormat.getDateInstance((DateFormat.MEDIUM)); Calendar currentDate1 = Calendar.getInstance(); Item_Date1 = formatter1.parse(datetime_text1); current_Date1 = formatter1.format(currentDate1.getTime()); current_System_Date1 = formatter1.parse(current_Date1); currentDate1.add(Calendar.DATE, -1); yesterdaydate = formatter1.format(currentDate1.getTime()); yeaterday_Date = formatter1.parse(yesterdaydate); currentDate1.add(Calendar.DATE, -2); threeDaysback = formatter1.format(currentDate1.getTime()); Three_Days_Back = formatter1.parse(threeDaysback); Here I am comparing current date with list view item date, and here is my problem, dates are matching but it is not entering in if condition I tried in so many ways but nothing worked the code for separator is bellow. if(Item_Date.compareTo(current_System_Date)==0){ if(index1){ emailListFeedAdapter.addSeparatorItem("SEPARATOR"); //i--; index1=false; } } else if(yeaterday_Date.compareTo(Item_Date1)==0){ if(index2){ emailListFeedAdapter.addSeparatorItem("SEPARATOR"); //i--; index2 = false; } } else if(Item_Date1.compareTo(Three_Days_Back)==0){ if(index3){ emailListFeedAdapter.addSeparatorItem("SEPARATOR"); //i--; index3 = false; } } } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } In EmailListFeedAdapter private TreeSet<Integer> mSeparatorsSet = new TreeSet<Integer>(); public void addSeparatorItem(final String item) { //itemss.add(emailResults.get(0)); // save separator position mSeparatorsSet.add(itemss.size() - 1); notifyDataSetChanged(); } @Override public int getItemViewType(int position) { return mSeparatorsSet.contains(position) ? TYPE_SEPARATOR : TYPE_ITEM; } holder = new ViewHolder(); switch (type) { case TYPE_ITEM: emailView= inflater.inflate(R.layout.email_listview_row, null); break; case TYPE_SEPARATOR: emailView= inflater.inflate(R.layout.item2, null); holder.textView = (TextView)emailView.findViewById(R.id.textSeparator); emailView.setTag(holder); holder.textView.setText("SEPARATOR"); break; } Here is ViewHolder class public static class ViewHolder { public TextView textView; } if anybody knows then please tell me where I am doing wrong. Thanx

    Read the article

1