
위에 그림 처럼 리니어 레이아웃으로 전부 weight 를 줘서 틀을 짯습니다. (네모 박스는 로고 지운거입니다 ㅎ)
리니어 레이아웃에 vertical 줘서 3개 리니어 만들어서 위 / 중간 / 아래 만들고
중간 리니어에 horize 줘서 왼쪽 / 가운데 / 오른쪽 만들고
가운데 리니어에 vertical 줘서 위/ 아래 2개의 리니어를 만들었습니다
이제 가운데에 위 / 아래 리니어에 editText를 넣으면 되는데
넣으니까 레이아웃이 변해버리네요.
이렇게 텍스트 박스 하나 때문에 중간 레이아웃이 커져버렸습니다.
editText 속성으로 height 를 fill_parent 로 ㅜ줬는데도 이러네요 ㅡㅜ 어떤 속성으로 어떻게 줘야 할까요?
(기본적으로 이미지 뷰등을 넣어도 마찬가지 증 상이네요. 사이즈를 줄여서 작게해도 가운데가 일단 커져버립니다.)
소스 입니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/login"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="724"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="162">
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="130"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="540"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="77"
android:orientation="vertical" >
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:inputType="textEmailAddress" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="77"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="130"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="394"
android:gravity="center"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
보다보니 가운데 레이아웃의 height가 android:layout_weight="162" 로 잡혀 있는것 같은데요 에디트 텍스트 를 감싸는 리니어의 height가 android:layout_weight="77" 로 잡혀 있고 그 아래 레이아웃역시 android:layout_weight="77" 로 되어있는 걸 보니까 사이즈 잡힌것은 154인데 가운데 레이아웃 height는 162로 되어있고..뭔가 안맞는것 같아요 거기에 editText를 fill_parent로 했기 때문이 아닌가 생각 됩니다. 레아아웃 구성을 다시해보시는게 좋을 것 같아요
제가 알기로는 weight 비율에서 weight 크기가 자기와 관련되어 있는 레이아웃들과의 비율이기 때문에
가운데 레이아웃이 162로 잡힌 것과 그 안에 레이아웃이 77으로 2개 잡혀 있는거는 상관없다고 알고 짜놓은 상태입니다.
162는 말그대로 전체 레이아웃에서 위:가운데:아래 의 비율이 724:162:394 의 비율로 될때 쓰는거고
77의 weight 는 중간 레이아웃에서 레이아웃 두개가 똑같이 77:77 이라서 1:1의 비율로 레이아웃을 나누기 위해서 쓴 것 입니다.
여기에 editbox를 넣었는데 가운데 레이아웃이 위로 밀리지 않는다면 fill_parent로 레이아웃안에 꽉 채우면 된다고 생각했는데
가운데의 크기가 커져버리는 증상이 있어서요 ^^;
혹시 weight로 떡칠하는 방법 외에는 해상도와 기기별 크기 대처해서 짜는거 추천해주실수 있나요 ^^?
EditText 백그라운드 이미지가 기본적으로 커서 그런 것 같네요 텍스트뷰의 백그라운드나 padding을 바꿔보시기 바랍니다.
그리고 fill_parent 의 네이밍이 2.2버전인가(?)부터 match_parent 로 변경되었습니다.
fill_parent로 사용하셔도 되지만 장기적으로 match_parent로 변경하시는 것을 권합니다.
올리신 레이아웃에는 별 문제가 없는것 같아요 800 * 480 해상도의 기기에서 했을때 첨부사진처럼 정상으로 나오고..에뮬레이터로 1280 * 720 해상도에서도 해봤는데 정상이에요;; 다른 기기에서 테스트 해보시거나 에뮬레이터로 한번 테스트해보는게 어떨까요? 올리신 레이아웃 소스는 문제가 없어보여요.




리니어 레이아웃 속성이 전부 android:orientation="vertical" 인것 같은데 ..vertical로는 3가지로 나누고 위에 가운데 아래 ;;
가운데 리니어는 horizontal 속성을 주어서 레이아웃을 구성하고 다시 그 안에 리니어에 vertical 속성을 주어서 만들어야 되지 않을까요?