Sunday, February 9, 2014

android how to load a custom layout file View


            
Ask you, I inherited a custom view class, now give this class is loaded under a layout file layout, how to operate?
Reply:
 
android: layout_width = "wrap_content"
android: layout_height = "match_parent"
android: layout_marginBottom = "10dp"
android: layout_marginLeft = "10dp"
android: layout_toRightOf = "@ + id / linearLayoutLeft">

android: id = "@ + id / tv_date"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android: layout_marginTop = "10dp"
android: background = "@ drawable / date_time_bg"
android: gravity = "center" />
<-!

Reply:
Like the bread directly name + class name on it
Reply:
I want to add this custom view another view class, with a seemingly impossible setContentView
Reply:
inflate it, then addview your own custom view inside, then your custom view to inherit ViewGroup
Reply:
addContentView
Reply:
Must first be set in the initialization of your view when.
1 reception View object LayoutInflater.from (context) inflate (R.layout you, null.);.
2 instantiate your control
3.this.setContentView (view);

No comments:

Post a Comment