안드로이드 개발 질문/답변
(글 수 45,052)
| LinearLayout( Relative로 구성해도 상관없음 ) = width:"fill_parent" height:"50dp" |
MapView = width:"fill_parent", height="위와 아래 50dp씩 차지하고 남은 공간 모두" |
| LinearLayout( Relative로 구성해도 상관없음 ) = width:"fill_parent" height:"50dp" |
레이아웃을 상단의 표와 같이 구성하고 싶습니다.
LinearLayout으로 구성해도 안되고 RelativeLayout으로 구성해도 안되더군요
결국 궁여지책으로 FrameLayout으로 구성했습니다만..
<?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:orientation="vertical">
<LinearLayout
android:id="@+id/top"
android:layout_width="fill_parent"
android:layout_gravity="top"
android:layout_height="50dp"
android:orientation="horizontal">
<Button android:id="@+id/btn_myloc"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:text="loc"/>
<View android:id="@+id/topview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"/>
<Button android:id="@+id/btn_createthread"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"/>
</LinearLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:clickable="true"
android:apiKey="zzzzzz"/>
<LinearLayout android:id="@+id/bottomtab"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:layout_below="@id/top">
<include layout="@layout/bottom_tap"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
</FrameLayout>
</LinearLayout>위와 같은 레이아웃을 구성해서 모양은 나왔는데
문제점은 FrameLayout에 있는 mapview에서 아랫쪽에 마진을 50주다보니
MapView에서 제스쳐이벤트 발생시에 좌표를 아랫쪽 + 50만큼 더 인식한다는 겁니다.
코드단에서 처리해줘도되지만 너무 궁여지책으로 코딩을 하는것 같아서 어떠한 해결방법이 있을지 고수님들의 이야기를 듣고 싶습니다.
2010.07.16 21:40:46
음...
RelativeLayout 을 사용하신 다음에,
MapView (아래의 예에서는 TextView)의 LayoutParam 값을 다음과 같이 설정하시면 원하는 Layout 을 구성하실 수 있을거 같습니다.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<View
android:id="@+id/view1"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_alignParentTop="true"
android:background="#00ff00"
/>
<View
android:id="@+id/view2"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:background="#00ff00"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/view1"
android:layout_above="@id/view2"
android:background="#ff0000"
/>
</RelativeLayout>
2010.07.16 22:20:10
버튼만 두개 쓴다는 가정하에 해본다 면 순서가 번튼두개를 먼저 작성해야 원하는대로 나옵니다. 맵뷰는 이미 작성된 버튼 두개를 기준으로 하구요ㅣ.
<RelativeLayout>
<Button
android:layout_width="fill_parent"
android:layout_height="50px"
android:layout_alignParentTop="true"
android:id="@+id/btn1"/>
<Button
android:layout_width="fill_parent"
android:layout_height="50px"
android:layout_alignParentTop="true"
android:id="@+id/btn2"/>
<com.google.android.maps.MapView android:id="@+id/map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/btn1"
android:layout_above="@id/btn2"
/>
<RelativeLayout>
전체는 모양은
<Relative>
<Linear1, layout_alignParentTop, button, view, button>
<Linear2, layout_alignParentBottom, button, view, button>
<MapView, layout_below@id:Linear1, layout_above@id:Linear2>
</Relative>
<RelativeLayout>
<Button
android:layout_width="fill_parent"
android:layout_height="50px"
android:layout_alignParentTop="true"
android:id="@+id/btn1"/>
<Button
android:layout_width="fill_parent"
android:layout_height="50px"
android:layout_alignParentTop="true"
android:id="@+id/btn2"/>
<com.google.android.maps.MapView android:id="@+id/map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/btn1"
android:layout_above="@id/btn2"
/>
<RelativeLayout>
전체는 모양은
<Relative>
<Linear1, layout_alignParentTop, button, view, button>
<Linear2, layout_alignParentBottom, button, view, button>
<MapView, layout_below@id:Linear1, layout_above@id:Linear2>
</Relative>



