简体   繁体   English

Android:Java中的Linearlayout之间的间距

[英]Android:Spacing between the Linearlayout in java

i am trying to give spacing between the views in a linearlayout programatically , i tried with layout.setPadding(0, 5, 0, 5); 我正在尝试以编程方式在线性布局中提供视图之间的间距,我尝试使用layout.setPadding(0, 5, 0, 5); but nothing worked ..also iam trying to put more space in one edittext field ..tried with this 但是没有任何效果..我也试图在一个edittext字段中放置更多空间..对此进行了尝试

comment.setLayoutParams(newandroid.view.ViewGroup.LayoutParams(450,100));

//comment.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));

here is my code: http://pastebin.com/s46qQUNV 这是我的代码: http : //pastebin.com/s46qQUNV

Give padding to each edittextview. 给每个edittextview填充。

    address.setpadding(0,5,0,5) ;
    addressCity.setpadding(0,5,0,5) ;
    addressState.setpadding(0,5,0,5) ;

should work. 应该管用。

Try to using LayoutParams : 尝试使用LayoutParams:

LinearLayout.LayoutParams params = new LinearLayout.LayoutParams
                     (LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1f);
params.setMargins(10, 0, 10, 0);
layout.setLayoutParams(params);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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