上下文
我正在尝试创建一个扩展LinearLayout的自定义视图。简而言之,此视图通过重写View.onDraw()方法来绘制自己的背景。背景周围有一个阴影(很像CardView)。
THE OBJECTIVE
因为背景就像带有阴影的卡片视图,所以不应该允许子视图填充整个视图。固定的填充应该留在周围的阴影卡。此填充不应受xml属性或setPadding()方法设置的填充的影响。它类似于CardView的setContentPadding()方法。
THE APPROACH
我正在尝试通过覆盖onLayout()的LinearLayout方法来实现这一点。官方文件说:
当此视图为其每个子视图
我需要从我的子布局中以编程的方式获得呈现参数。目前我是这样做的:
var sublayout = ((Sublayout)this.Parent);
//Get all rendering
var renderings = Sitecore.Context.Item.Visualization.GetRenderings(Sitecore.Context.Device, true);
//Get the first rendering that matches the current sublayout's path
var sublayoutRendering = renderin
我有一个ScrollView,它包含许多buttons和textviews。
我希望insert a new button中途(索引3)在滚动视图,但得到错误,"ScrollView只能承载一个直接子“。
这不可能吗?
Button b = new Button(this);
scrView.AddView(b,3);
?