Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/182.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android:一个相对布局的子对象要么相互重叠,要么只有最后一个或第一个可见_Android_Android Relativelayout - Fatal编程技术网

Android:一个相对布局的子对象要么相互重叠,要么只有最后一个或第一个可见

Android:一个相对布局的子对象要么相互重叠,要么只有最后一个或第一个可见,android,android-relativelayout,Android,Android Relativelayout,我使用此代码从源代码获取内容,因此使用动态初始化 问题是createcomment生成的视图彼此重叠 如何避免重叠 createdynamic createcomments 我使用以下语句 for(ka=0;ka<jsarray.length();ka++){ createdymanic(ka); // setting on click listener and all for(int i=0;i<comment_array.length();i++){

我使用此代码从源代码获取内容,因此使用动态初始化

问题是createcomment生成的视图彼此重叠

如何避免重叠

createdynamic

createcomments

我使用以下语句

for(ka=0;ka<jsarray.length();ka++){
    createdymanic(ka);

    // setting on click listener and all

    for(int i=0;i<comment_array.length();i++){
    createcomment(i);

        // detting onclicklistener and all
    }
}

看起来您要添加的上一个文本视图TVComentContent没有右边界,因此您要添加的第三个TVComentDate和第四个视图TVComentContent重叠。尝试添加

textcommentbody.addRule(RelativeLayout.LEFT_OF, tvcommentdate.getId());
就在你的头顶上

textcommentbody.setMargins(5,0,0,0);
线路。这应该确保最后一个视图位于第三个视图的左侧。为了更好地展示这一点,我用MS paint制作了一个甜美的图表,但显然新用户无法添加图像:


我希望这有帮助

很抱歉提出了这样一个蹩脚的问题

问题是commentlayout方向的默认值默认为水平

以下代码解决了该问题:

commentlayout= new LinearLayout(getActivity());
commentlayout.setOrientation(LinearLayout.VERTICAL);

我想你把我的问题搞错了。在我的代码中根据我添加了clayout,但最后一个只显示其中一个。
textcommentbody.setMargins(5,0,0,0);
commentlayout= new LinearLayout(getActivity());
commentlayout.setOrientation(LinearLayout.VERTICAL);