학교 수업시간에 나온 실습문제인데요...

첨부된 이미지에 나온것처럼,

화면을 구성해야하는데 코드로 하는것이라 어려움이 많은것 같습니다 (ㅆ_ㅆ)


package exam.imbeded01;


import android.app.Activity;

import android.os.Bundle;

import android.view.ViewGroup;

import android.widget.LinearLayout;

import android.widget.TextView;


public class Imbededex01Activity extends Activity{

public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

       

        LinearLayout baseLayout = (LinearLayout) findViewById(R.id.toplayout); 

        LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(

        LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1);

        baseLayout.setOrientation(LinearLayout.VERTICAL);

       

       

        {

        LinearLayout background1Layout = new LinearLayout(this); 

        background1Layout.setOrientation(LinearLayout.HORIZONTAL); 

        background1Layout.setBackgroundColor(android.graphics.Color.RED); 

        

        baseLayout.addView(background1Layout, p);

        

        TextView tv = new TextView(this);

        tv.setText("이건 제일 위에");

        LinearLayout.LayoutParams tvParams = new LinearLayout.LayoutParams(

        ViewGroup.LayoutParams.WRAP_CONTENT,

        ViewGroup.LayoutParams.MATCH_PARENT,0.0F);

        //tvParams.

        tv.setLayoutParams(tvParams);

        background1Layout.addView(tv);

        setContentView(baseLayout);

        

        //두번째로 쓸것.

        

        LinearLayout background3Layout = new LinearLayout(this);

        background3Layout.setOrientation(LinearLayout.HORIZONTAL); 

        background3Layout.setBackgroundColor(android.graphics.Color.BLUE); 

        baseLayout.addView(background3Layout, p);

        

        TextView tv2 = new TextView(this);

        tv2.setText("이건 중간에 펴서");

        LinearLayout.LayoutParams tv2Params = new LinearLayout.LayoutParams(

        ViewGroup.LayoutParams.FILL_PARENT,

        ViewGroup.LayoutParams.FILL_PARENT,0.0F);

        tv2.setLayoutParams(tv2Params);

        background3Layout.addView(tv2);

        setContentView(baseLayout);

       

        

        

        //세번째로 쓸것.

        LinearLayout background2Layout = new LinearLayout(this);

        background2Layout.setOrientation(LinearLayout.HORIZONTAL); 

        background2Layout.setBackgroundColor(android.graphics.Color.GREEN); 

        baseLayout.addView(background2Layout, p);

        

        TextView tv1 = new TextView(this);

        tv1.setText("이건 제일 아래에");

        LinearLayout.LayoutParams tv1Params = new LinearLayout.LayoutParams(

        ViewGroup.LayoutParams.WRAP_CONTENT,

        ViewGroup.LayoutParams.MATCH_PARENT,0.0F);

        tv1.setLayoutParams(tv1Params);

        background2Layout.addView(tv1);

        setContentView(baseLayout);

       


       

}}

}




코드는 이런식으로 작성했는데

핸드폰으로 실행시켜보면 빨간색 파란색 초록색이 정확하게 3등분이 되서 나옵니다 ㅠ.ㅠ

제 머리로서는 저것만이 정답인것같은데 어디가 틀린걸까요? 알려주시면 감사하겠습니다