2017-01-28 4 views
-1

Часть моего пользовательского интерфейса отключается при установке на реальном устройстве Android. Он использует API карт Google. Кнопка «Мое местоположение» немного отходит от экрана.Android-студия: контент уходит с экрана

Также карта не покрывает весь экран, даже если это происходит в представлении пользовательского интерфейса в Android Studio.

<LinearLayout xmlns:map="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical"> 

<LinearLayout 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

<EditText 
    android:layout_width="269dp" 
    android:layout_height="wrap_content" 
    android:inputType="textPersonName" 
    android:ems="10" 
    android:id="@+id/SearchLocationText" 
    android:hint="Search Location" 
    android:textCursorDrawable="@drawable/black_cursor" 
    /> 

<Button 
    android:text="Search" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/SearchButton" 
    android:onClick="onSearch" /> 

</LinearLayout> 

<fragment 
    android:id="@+id/map" 
    android:name="com.google.android.gms.maps.SupportMapFragment" 
    tools:context="com.anand.projectv10.MapsActivity1" 
    android:layout_height="519dp" 
    android:layout_width="382dp" /> 

+0

Вы можете разместить снимок экрана? и теперь чего вы хотите достичь? Также обратите внимание, что вы дали жесткие кодовые значения по всему вашему виду, чтобы это произошло! например: width = "269dp, height =" 519dp –

+0

Я добавил скриншот сейчас. –

+0

Я уже дал ответ! –

ответ

0

У вас есть предварительный просмотр того, что вы разрабатываете на андроид studio.So вы будете проектировать что-то, чтобы покрыть этот экран, но обратите внимание, что каждый экран не с теми же размерами (ширина/высота/дюйм). Когда вы делаете хардкорные значения, существует высокая вероятность того, что позиции представления не совпадают с реальными сценариями. Значения, назначенные на основе коэффициентов, всегда прилипают хорошо.

Вы можете использовать weightSum и layout_weight добиться того, что вы хотите без жесткого кодирования значений

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:weightSum="5"> 

      <EditText 
       android:id="@+id/SearchLocationText" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="4" 
       android:ems="10" 
       android:hint="Search Location" 
       android:inputType="textPersonName" 
       android:textCursorDrawable="@drawable/black_cursor" /> 

      <Button 
       android:id="@+id/SearchButton" 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:onClick="onSearch" 
       android:text="Search" /> 

     </LinearLayout> 

     <fragment 
      android:id="@+id/map" 
      android:name="com.google.android.gms.maps.SupportMapFragment" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      tools:context="com.anand.projectv10.MapsActivity1" /> 

    </LinearLayout> 

Для дальнейшего понимания Читать What is android:weightSum in android, and how does it work?

What does android:layout_weight mean?

+0

@Anand Pimple вам удалось заставить его работать? –

Смежные вопросы