大佬教程收集整理的这篇文章主要介绍了Xamarin Android中的动态嵌套相对布局,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是针对Category的,我通过在布局中编写.axml看起来很好.现在,当用户点击类别时,应该在其点击上生成相同的外观并且它正在动态创建,但子内容与父内容重叠,如下所示:
为了使子相对布局我写下面的代码:
RelativeLayout childTaxonomylayout = new RelativeLayout( this ); childTaxonomylayout.Id = Convert.ToInt32( data.Value.Id ); childTaxonomylayout.SetOnClickListener( this ); var param = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent,ViewGroup.LayoutParams.WrapContent ); param.AddRule(LayoutRules.AlignParentBottom); param.AddRule( LayoutRules.AlignParentLeft ); childTaxonomylayout.LayoutParameters = param; TextView textViewChild = new TextView( this ); textViewChild.Text = data.Value.Item.Name; textViewChild.SetPadding( 20,10,10 ); textViewChild.Id = Convert.ToInt32( data.Value.Id ); RelativeLayout.LayoutParams rlp2 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FillParent,RelativeLayout.LayoutParams.WrapContent ); rlp2.AddRule( LayoutRules.AlignParentBottom ); rlp2.AddRule( LayoutRules.AlignParentLeft ); textViewChild.LayoutParameters = rlp2; childTaxonomylayout.AddView( textViewChild ); if (data.Value.Children.Count != 0) { var _imgViewClose = new ImageView( this ); _imgViewClose.Id = Convert.ToInt32( "123" + data.Value.Id.ToString() ); _imgViewClose.SetImageresource( resource.Drawable.ic_right ); RelativeLayout.LayoutParams rlp1 = new RelativeLayout.LayoutParams(30,20 ); rlp1.AddRule( LayoutRules.AlignParentBottom ); rlp1.AddRule( LayoutRules.AlignParentright ); childTaxonomylayout.AddView( _imgViewClose ); } childLayout.AddView( childTaxonomylayout );
请让我知道我应该更改什么才能使我的用户界面正确无误.谢谢
以上是大佬教程为你收集整理的Xamarin Android中的动态嵌套相对布局全部内容,希望文章能够帮你解决Xamarin Android中的动态嵌套相对布局所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。