2017-01-28 19 views
-1

実際のアンドロイドデバイスにインストールすると、UIの一部が画面に表示されなくなります。 Google Maps APIを使用します。 「私の場所」ボタンが画面から少し離れます。Androidスタジオ:コンテンツが画面に表示されない

また、Android StudioのUIプレビューでも、地図全体が完全な画面に表示されません。

<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に設計されているもののプレビューを持っています)。値をハードコアにすると、実際のシナリオではビューの位置が間違ってしまう可能性が高くなります。比率に基づいて割り当てられた値は常に固定されます。あなたはさらに理解するためにハードコーディング値

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

せずに、あなたが望むものを達成するためにweightSumlayout_weightを使用することができます

What is android:weightSum in android, and how does it work?

What does android:layout_weight mean?

+0

@Anand Pimpleさんはあなたがそれを機能させるために管理しましたか? –

関連する問題