android - Custom Linear layout with round corner -


i tried draw custom linear layout, problem faced not getting round corner linear layout

 public class roundlinearlayout extends linearlayout {   private float radius; private path path = new path(); private rectf rect = new rectf();   public roundlinearlayout(context context) {     super(context);     radius = 20;    // setwillnotdraw(false); }   public roundlinearlayout(context context, attributeset attrs) {     super(context, attrs);    // init(context); }  public roundlinearlayout(context context, attributeset attrs, int defstyle) {     super(context, attrs, defstyle);    // init(context); } @override protected void ondraw(canvas canvas) {     path.reset();     rect.set(0, 0, canvas.getwidth(), canvas.getheight());     path.addroundrect(rect, radius, radius, path.direction.ccw);     // add 1px border red here ?     path.close();     canvas.clippath(path); } } 

i donno went wrong.. please me sort out.

i suggest use simple cardview

use compile dependency

compile 'com.android.support:cardview-v7:21.0.+' 

example

<android.support.v7.widget.cardview         xmlns:card_view="http://schemas.android.com/apk/res-auto"         android:layout_width="match_parent"         android:layout_height="wrap_content">  <linearlayout ..... other child layout goes here </linearlayout> </android.support.v7.widget.cardview> 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -