RelativeLayout layout = (RelativeLayout)findViewById(R.id.rl);
        for(int i = 1; i <= count; i++)
        {
            final TextView textViewUtente = new TextView(mContext);
            final TextView textViewMessaggio = new TextView(mContext);
            final TextView textViewData = new TextView(mContext);
            textViewUtente.setText(sepUser[i]);
            textViewMessaggio.setText(sepMessage[i]);
            textViewData.setText(sepDate[i]);
            int curTextViewIdUtente = 1000+i;
            int curTextViewIdMessaggio = 2000+i;
            int curTextViewIdData = 3000+i;
            textViewUtente.setId(curTextViewIdUtente);
            textViewMessaggio.setId(curTextViewIdMessaggio);
            textViewData.setId(curTextViewIdData);
            final RelativeLayout.LayoutParams params =
                    new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
                            RelativeLayout.LayoutParams.WRAP_CONTENT);
            params.topMargin= 100+i*150;
            textViewUtente.setLayoutParams(params);
            layout.addView(textViewUtente, params);
            params.topMargin= 250+i*150;
            textViewMessaggio.setLayoutParams(params);
            layout.addView(textViewMessaggio, params);
            params.topMargin= 100+i*150;
            params.rightMargin=200;
            textViewData.setLayoutParams(params);
            layout.addView(textViewData, params);
        }
我需要创建 3 个文本视图(从用户创建博客上的帖子)每个 for 循环,如下所示:
帖子 1:
TextViewUSer TextViewDate
文本视图消息
帖子 2:
TextViewUSer TextViewDate
文本视图消息
我可以将一个博客的帖子(一组文本视图)放在另一个之上。我只是可以将它们定位,就像这样,从彼此。他们把一个粘在另一个上面。
我也用 addRules 验证了 .ABOVE 和其他人,但更糟糕的是,它们都卡在了左上角