#android #android-layout #layout
#Android #android-layout #макет
Вопрос:
Пожалуйста, смотрите прилагаемый снимок экрана, я показываю всплывающие окна с изображением, используя Google Maps Version2
Я ищу три небольших изменения в моем всплывающем окне, и это:
- хотите показать изображение на полном фоне, например, все еще мое изображение, покрывающее только 50% площади маркера
- также нужно покрыть белую область маркера (белый по углам)
- а что, если я хочу показать черные тени по углам
popup.xml:-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/background_dark"
android:orientation="horizontal">
<ImageView
android:id="@ id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:background="@null"
android:adjustViewBounds="true"
android:contentDescription="@string/icon"/>
<TextView
android:id="@ id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:textColor="@android:color/background_light"
android:layout_marginTop="5dp"
android:textSize="18sp"
android:typeface="sans"
android:textStyle="bold"/>
<TextView
android:id="@ id/snippet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@ id/title"
android:typeface="sans"
android:textStyle="bold"
android:textSize="18sp"
android:maxLines="1"
android:textColor="@android:color/background_light" />
</RelativeLayout>
Я думаю, что мне нужно использовать более широкое изображение в качестве фона маркера, все еще используя это, и меня беспокоят эти белые углы (я не хочу этого видеть)
Ответ №1:
Измените четыре «wrap_content» в вашем RelativeLayout и ImageView на «Match_parent». Однако imageview может выглядеть растянутым, поэтому вам следует рассмотреть возможность использования более широкого.
Ответ №2:
Замените ImageView на this ( измените wrap_content на match_parent )
<ImageView
android:id="@ id/icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:background="@null"
android:contentDescription="@string/icon"/>
……rest xml-код
Комментарии:
1. используя match_parent для ImageView, он показывает маркер полной ширины с изображением в центре, что совершенно неправильно и не требуется
2. @Sonali вы пробовали это, что происходит, когда вы применяете это.?
Ответ №3:
<ImageView
android:id="@ id/icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:background="@null"
android:scaleType="fitxy"
android:contentDescription="@string/icon"/>
Ответ №4:
Попробуйте этот способ, надеюсь, это поможет вам решить вашу проблему.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:background="@drawable/background"> // Here set your custom pop window background with with and black shadow
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/ic_launcher"> // Here set your place image
<TextView
android:id="@ id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:textColor="@android:color/background_light"
android:layout_marginTop="5dp"
android:textSize="18sp"
android:typeface="sans"
android:text="Great Hotel - A Luxury Sun"
android:textStyle="bold"/>
<TextView
android:id="@ id/snippet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:typeface="sans"
android:textStyle="bold"
android:textSize="18sp"
android:maxLines="1"
android:layout_marginTop="10dp"
android:text="$359"
android:textColor="@android:color/background_light" />
</LinearLayout>
</LinearLayout>
Комментарии:
1. @Sonali, хорошо, поэтому попробуйте определить идентификатор для этого макета и установить фоновое изображение во время выполнения.