2017-01-28 3 views
-1

Teil meiner Benutzeroberfläche geht Off-Bildschirm, wenn auf einem tatsächlichen Android-Gerät installiert. Es nutzt die Google Maps API. Die Schaltfläche "Mein Standort" wird ein wenig vom Bildschirm entfernt.Android Studio: Inhalt geht aus dem Bildschirm

Auch die Karte deckt nicht den gesamten Bildschirm ab, obwohl dies in der UI-Vorschau in Android Studio der Fall ist.

<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

können Sie einen Screenshot posten? und was willst du jetzt erreichen? Beachten Sie auch, dass Sie in Ihrer Ansicht harte Codewerte angegeben haben, damit das passieren kann !! zB: width = "269dp, height =" 519dp –

+0

Ich habe jetzt einen Screenshot hinzugefügt. –

+0

Ich habe die Antwort schon gegeben! –

Antwort

0

Sie haben eine Vorschau von dem, was Sie bei android studio.So entwerfen Sie etwas entwerfen wird, dass Bildschirm zu decken, aber beachten Sie, dass jeder Bildschirm nicht mit den gleichen Abmessungen ist (Breite/Höhe/dpi). Wenn Sie Hardcore-Werte haben, besteht eine hohe Wahrscheinlichkeit, dass die Sichtpositionen in realen Szenarien falsch sind. Die Werte, die auf der Grundlage von Verhältnissen zugewiesen werden, bleiben immer in Ordnung.

können Sie weightSum verwenden und layout_weight zu erreichen, was Sie ohne harte Codierung Werte wollen

<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> 

Zum weiteren Verständnis lesen What is android:weightSum in android, and how does it work?

What does android:layout_weight mean?

+0

@Anand Pimple hast du es geschafft, damit es funktioniert? –

Verwandte Themen