학교 과제가 코드로 레이아웃 만드는건데
만들어야하는 결과화면이 안나와요 ㅠㅠ
제가보기엔 맞는거같은데
맨마지막 텍스트뷰를 인식을 못해서
두번째 텍스트뷰가 세번째 텍스트뷰의 자리까지 다 차지해버렸네요
어떻게하면 세번째 텍스트뷰가 보일까요 ㅠㅠ...
결과화면은 첫번째 텍스트뷰랑 세번째 텍스트뷰가 한줄로 나오고
두번째 텍스트뷰가 첫번째랑 세번째 텍스트뷰 뺀 화면 전체를 차지하는거에요!
코드 보여드릴게요
package exam.imbeded01;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Gravity;
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);
LinearLayout linear = new LinearLayout(this);
linear.setOrientation(LinearLayout.VERTICAL);
linear.setGravity(Gravity.CENTER);
TextView text = new TextView(this);
text.setText("첫번째");
text.setBackgroundColor(Color.RED);
LinearLayout.LayoutParams paramtext = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
linear.addView(text, paramtext);
setContentView(linear);
TextView text1 = new TextView(this);
text1.setText("두번째");
text1.setBackgroundColor(Color.BLUE);
LinearLayout.LayoutParams paramtext1 = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT);
linear.addView(text1, paramtext1);
setContentView(linear);
TextView text2 = new TextView(this);
text2.setText("세번째");
text2.setBackgroundColor(Color.GREEN);
LinearLayout.LayoutParams paramtext2 = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
linear.addView(text2, paramtext2);
setContentView(linear);
}
}
찾아주시면 감사하겠습니다 ㅠ_ㅠ
두번째 텍스트뷰의 높이부분을 0으로 넣어주시고 weight값을 1로 주세요 그럼 해결될겁니다.
이건 weight 값이 존재하면 높이를 무시하고 weight에 의한 높이를 계산하기 때문입니다.