2017-10-11 20 views
-1

프레임 레이아웃에서 Google지도를 사용하는 애플리케이션이 있습니다. 나는 대체 대답 2 this (대답) 답변을 사용하고 있습니다. 대안 2를 사용할 때 응용 프로그램 상단에 단일 단추가 있습니다 (자유 그리기). 내 질문은이 단추의 측면에 둘 이상의 단추 (가로/세로)를 추가 할 수 있습니까?프레임 레이아웃 (안드로이드)에 여러 개의 버튼 추가

나는 비슷한 질문을 온라인으로 검색했지만 대개 대답은 두 개의 개별 레이아웃을 포함합니다. 나는 안드로이드 초보자이며 두 개의 레이아웃을 어떻게 사용하는지 모른다. 두 개의 레이아웃을 사용했지만 "다중 루트 태그"오류가 발생했습니다. 이 문제를 해결할 수있는 방법이 있습니까?

도움이 될 것입니다. 당신의 root_map.xml이 같은

답변

0

뭔가지도의 왼쪽 상단 모서리에 당신이 서로 옆에 두 개의 버튼을 제공합니다 :

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <fragment 
     android:id="@+id/map" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     class="com.google.android.gms.maps.SupportMapFragment" /> 

    <LinearLayout 
     android:id="@+id/fram_map" 
     android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <Button 
      android:id="@+id/btn_draw_State" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Free Draw" /> 

     <Button 
      android:id="@+id/btn_dosomethingelse" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Do Something Else" /> 

    </LinearLayout> 

</FrameLayout> 
0

예, 물론. 원하는만큼 단추를 추가 할 수 있습니다. FrameLayout 내에서의 위치를 ​​제어하려면 android:layout_gravity 속성을 사용하여 각 하위에 중력을 지정해야합니다.

예 :

<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <com.google.android.gms.maps.MapView 
     android:id="@+id/map" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom"> 

     <Button 
      android:id="@+id/buttonA" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Button A"/> 
     <Button 
      android:id="@+id/buttonB" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Button B"/> 
    </LinearLayout> 
</FrameLayout> 

당신의 오류에 관한 "여러 루트 태그"Multiple root tags in Android Studio