안드로이드 개발 질문/답변
(글 수 45,052)
제가 위 그림과 같이 스피너와 에디트텍스트2개가 들어간 로그인 창을 만들고 싶은데
이것을 자바 소스로 짠다음 아래와 같이 xml안에 넣고 싶습니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
>
<woong.test.customview3.LoginView
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
LinearLayout을 상속받은 LoginView클래스에 스피너와 에디트텍스트를 넣어서
불러오는것 까지는 성공을 했는데 위와같은 모양으로는 어떻게 만들어야 하는지 모르겠습니다.
혹시 위와같이 여러개의 위젯을 넣어서 만든 레이아웃을 공부할 수 있는 참고 사이트 아시는 분들
알려 주시면 감사하겠습니다.
자바 코드로 레이아웃을 만드는게 쉽지 않다는건 알고 있었지만 구글링을 잘 못해서 그런지 너무 어렵네요~~
아래는 제가 자바코드로 짠 레이아웃입니다.
public class LoginView extends LinearLayout {private Spinner sp = null;
private EditText et1 = null;
private EditText et2 = null;
public LoginView(Context context, AttributeSet attrs) {super(context, attrs);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
0.0F);
this.setLayoutParams(params);
this.setBackgroundColor(Color.GREEN);
this.sp = new Spinner(context);
this.et1 = new EditText(context);
this.et2 = new EditText(context);
this.addView(this.sp, new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
this.addView(this.et1, new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
this.addView(this.et2, new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
}
}



