使用mapview时无法将视图拆分为两个。它在预览视图中正确显示

时间:2017-04-03 13:08:49

标签: android layout android-mapview

使用mapview时无法将视图拆分为2。它在预览视图中正确显示。我尝试了相对布局和所有。但没有任何帮助。大概占据屏幕尺寸的3/4。我试过无效并重新启动android studio。我不知道我犯了哪个错误。任何人都知道,回答我。帮助将不胜感激。

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical">

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

<LinearLayout

    android:id="@+id/lnrMeetingParticipants"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:layout_weight="0.5">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/min_padding"
        android:background="@android:color/transparent"
        android:hint="Desc"
        android:textColorHint="@color/gray"
        android:textColor="@color/gray"
        android:layout_weight="1"
        android:textSize="20sp"/>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/min_padding"
        android:textColor="@color/gray"
        android:textColorHint="@color/gray"
        android:background="@android:color/transparent"
        android:textSize="20sp"
        android:layout_weight="1"
        android:hint="Location"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_weight="1">

        <TextView
            android:id="@+id/cstmTxtTrackParticipant"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_toLeftOf="@+id/switchRingtone"
            android:layout_toStartOf="@+id/switchRingtone"
            android:padding="@dimen/min_padding"
            android:text="Ringtone"
            android:textSize="20sp"

            android:textColor="@color/gray"
            app:font="@string/robotto_light" />


        <com.kyleduo.switchbutton.SwitchButton
            android:id="@+id/switchRingtone"
            style="@style/SwitchButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:textColor="@android:color/white"
            android:textSize="16dp"
            app:kswBackDrawable="@drawable/switch_back_drawable"
            app:kswTextOff="OFF"

            app:kswTextOn="ON"
            app:kswThumbDrawable="@drawable/switch_thumb_drawable"
            app:kswTintColor="@color/colorPrimary" />


    </RelativeLayout>
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center"
        android:weightSum="1">

        <TextView
            android:id="@+id/cstmTxtReminderVibration"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_toLeftOf="@+id/switchVibration"
            android:layout_toStartOf="@+id/switchVibration"
            android:padding="@dimen/min_padding"
            android:textColor="@color/gray"
            android:textSize="20sp"
            android:text="Vibration"
            app:font="@string/robotto_light" />


        <com.kyleduo.switchbutton.SwitchButton
            android:id="@+id/switchVibration"
            style="@style/SwitchButtonStyle"
            android:layout_width="25dp"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:textColor="@android:color/white"
            android:textSize="16dp"
            android:padding="@dimen/min_padding"
            app:kswBackDrawable="@drawable/switch_back_drawable"
            app:kswTextOff="OFF"
            app:kswTextOn="ON"
            app:kswThumbDrawable="@drawable/switch_thumb_drawable"
            app:kswTintColor="@color/colorPrimary" />


    </RelativeLayout>

   </LinearLayout>


  </LinearLayout>

更新

image

现在我使用ImageView进行了更新。将可见性设置为mapview。然后添加了Imageview

 <ImageView

    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.5"
    android:src="@drawable/user"
    />

现在视图看起来像

imageview

1 个答案:

答案 0 :(得分:0)

android:layout_height="match_parent"改为android:layout_height="0dp"改为MapView及其下方的LinearLayout