简体   繁体   中英

Create custom viewgroup in android

I want to create a custom view this view and when add a view to XML I want to add static child view(textview,imageButtom and...) into custom view like cardview and final view look like this picture .how can we create a view?

You could start by extending an already defined layout like relative layout because creating a layout from scratch and implementing all methods in it is a little hard process. First thing came to my mind is adding a padding the custom layout for edge perspective effects so the layout don't place any view to this area. Then you can draw you perspective effect in onDispatchDraw() method. This method provide you with to draw canvas of the layout. In addition, using an drawable like nine patch as background makes things easier compared to custom drawing operation. In summary, you should give padding the layout to prevent overlapping with edge perspective. Then draw or set a background for the layout.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM