草庐IT

marginLayoutParams

全部标签

c# - 动画 TopMargin 的 ObjectAnimator 代理找不到设置/ getter

我们正在尝试使用objectanimator代理来为Android(Xamarin)中的TopMargin属性设置动画。但是,我们得到这个错误:[PropertyValuesHolder]Couldn'tfindsetter/getterforpropertyTopMarginwithvaluetypefloat注意:我们尝试了TopMargin、topMargin、GetTopMargin、getTopMargin等方法,认为可能是Java和C#之间大小写转换的问题,但看起来并不是。我们在启动动画的Activity中的代码:translation=newint[]{0,300};va

android - 如何以编程方式更改 Android ListView 的布局边距

我在xml中定义了一个ListView,如下所示我需要根据程序中的某些结果重新定义布局边距,我该如何实现这一点 最佳答案 更简单地说,您可以修改现有的MarginLayoutParams实例来修改边距:ViewGroup.MarginLayoutParamsmlp=(ViewGroup.MarginLayoutParams)mListView.getLayoutParams();mlp.setMargins(adjustmentPxs,0,0,0);break; 关于android-如何

android - 以编程方式在 View 上设置负边距

我知道如何使用LinearLayout.LayoutParams和方法setMargins(int,int,int,int)以编程方式设置View的边距>但是我怎样才能在View上设置负边距呢? 最佳答案 访问父布局的布局参数并根据需要修改它们:ViewGroup.MarginLayoutParamsparams=(ViewGroup.MarginLayoutParams)view.getLayoutParams();params.topMargin=...;//etc//orparams.setMargins(...);修改布局后

安卓:ViewGroup.MarginLayoutParams 不工作

我用它以编程方式设置边距,但它不起作用,边距未应用。在构造函数中:publicTimeWindow(Contextcontext,intpixels,intleft,inttop){super(context);ViewGroup.MarginLayoutParamsparams=newViewGroup.MarginLayoutParams(pixels,pixels);params.setMargins(left,top,0,0);this.setLayoutParams(params);} 最佳答案 从您的评论中推断,当您的V