2016-08-24 1 views
0

InfoWindowに現在の場所と場所の名前を表示しているGoogleマップがあります。それはうまくいっていますが、場所名が長すぎると、その時点で、テキスト全体がthisのようなInfoWindowで正しく表示されないという問題があります。このInfowindowのサイズを変更するにはどうすればよいですか? 私のコードは以下の通りです:Infowindowのサイズを変更する

private class CustomInfoWindowAdapter implements GoogleMap.InfoWindowAdapter { 

     private View view; 

     public CustomInfoWindowAdapter() { 
      view = getLayoutInflater().inflate(R.layout.info_window, null); 

      view.setLayoutParams(new RelativeLayout.LayoutParams(500, RelativeLayout.LayoutParams.WRAP_CONTENT)); 
     } 

     @Override 
     public View getInfoContents(Marker marker) { 

      if (CheckIn.this.marker != null && CheckIn.this.marker.isInfoWindowShown()) { 
       CheckIn.this.marker.hideInfoWindow(); 
       CheckIn.this.marker.showInfoWindow(); 
      } 
      return null; 
     } 

     @Override 
     public View getInfoWindow(final Marker marker) { 
      CheckIn.this.marker = marker; 

      String url = null, isLoaded = "0"; 

      /*if (marker.getId() != null && markers != null && markers.size() > 0) { 
       if (markers.get(marker.getId()) != null && markers.get(marker.getId()) != null) { 
        url = markers.get(marker.getId()); 
        isLoaded = markers.get(marker.getId() + marker.getTitle()); 
       } 
      }*/ 
      final ImageView imgAddress = ((ImageView) view.findViewById(R.id.imgAddress)); 

      final String title = marker.getTitle(); 

      final CustomTextView txtTitle = ((CustomTextView) view.findViewById(R.id.txtTitle)); 
      if (title != null) { 
       /*txtTitle.setText("La Brasserie Bordelaise");*/ 
       mProgressDialog.dismiss(); 
       txtTitle.setText(currentPlaceName); 
       txtTitle.setOnClickListener(new View.OnClickListener() { 
        @Override 
        public void onClick(View v) { 
         Toast.makeText(CheckIn.this, title, Toast.LENGTH_LONG).show(); 
        } 
       }); 
      } else { 
       txtTitle.setText(""); 
      } 

      return view; 
     } 
    } 

私のXMLは、全体のレイアウトのための静的な幅を設定している

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


    <RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="@dimen/margin_120" 
     android:layout_centerHorizontal="true" 
     android:layout_marginLeft="@dimen/margin_30" 
     android:layout_marginRight="@dimen/margin_30" 
     android:background="@drawable/bg_info_window"> 

     <RelativeLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="@dimen/margin_5"> 

      <RelativeLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="3dp" 
       android:layout_marginLeft="@dimen/margin_5" 
       android:layout_marginRight="@dimen/margin_5" 
       android:layout_toLeftOf="@+id/imgAddress"> 

       <com.widget.CustomTextView 
        android:id="@+id/txtTitle" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="5dp" 
        android:inputType="textMultiLine" 
        android:maxLines="2" 
        android:singleLine="false" 
        android:text="aaaa" 
        android:textColor="@android:color/black" 
        android:textSize="@dimen/text_size_16" 
        customFont:fontTextStyle="3" /> 
       <!--android:text="La Brasserie Bordelaise"--> 


       <LinearLayout 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/txtTitle" 
        android:layout_marginLeft="@dimen/margin_5" 
        android:orientation="horizontal"> 

        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_marginTop="@dimen/margin_5" 
         android:src="@drawable/ic_person" /> 

        <com.widget.CustomTextView 
         android:id="@+id/txtTotalPeople" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginLeft="5dp" 
         android:inputType="textMultiLine" 
         android:singleLine="false" 
         android:text="aaaa" 
         android:textColor="@color/colorDetailGray" 
         android:textSize="@dimen/text_size_medium" 
         customFont:fontTextStyle="3" /> 
       </LinearLayout> 
      </RelativeLayout> 

      <ImageView 
       android:id="@+id/imgAddress" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_centerVertical="true" 
       android:contentDescription="@string/app_name" 
       android:padding="@dimen/padding_10" 
       android:src="@drawable/ic_right_arrow" /> 
     </RelativeLayout> 
    </RelativeLayout> 
</RelativeLayout> 

答えて

0

を下回っています。

ソリューション1

変更

view.setLayoutParams(new RelativeLayout.LayoutParams(500, RelativeLayout.LayoutParams.WRAP_CONTENT)); 

view.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT)); 

ソリューション2

するMAXLINESを設定することでのTextViewの複数行を作ります2または3 のようなtxtTitle.setMaxLines(2)

+0

ごめんなさい!それは私のために働いていない! –

+0

Info_Windowレイアウトに2つのTextViewが含まれているので、InfoWindowから2番目のテキストビューが表示されます。 –

+0

これを今すぐ試すことができないので、画像を投稿できますか?画面を掲示し、IDを記入してください。 –

関連する問題