我尝试为GoogleMaps实现Map View balloon
,但我阻止了气球的布局。
气球的大小必须是内容大小,但是,它需要背景可绘制大小,因为它的大小较大。由于我有一个相当大的气球9-patch image
,由其他人提供,一个小型气球内容需要所有的屏幕(可绘制的大小)。如何包装内容视图而不是后台可绘制?
只见此相关的问题:How to wrap content views rather than background drawable?,这正是我想要的,但它没有正确的答案(使用FrameLayout
作出了同样的问题,因为ImageView
SRC将采取绘制尺寸也与wrap_content
或fill_parent
) 。
这里是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:id="@+id/balloon_main_layout"
android:orientation="horizontal" android:clickable="true"
android:focusable="true" android:focusableInTouchMode="true"
android:layout_width="wrap_content" android:background="@drawable/info_bulle_selector">
<LinearLayout android:id="@+id/linearLayout1"
android:layout_height="wrap_content" android:layout_width="0dp"
android:layout_weight="1">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="TextView"
android:id="@+id/balloon_item_title" android:textColor="#ffffff"></TextView>
</LinearLayout>
<ImageView android:id="@+id/balloon_close"
android:layout_marginLeft="5dp" android:src="@drawable/fermer_selector"
android:scaleType="fitXY" android:layout_height="30dp"
android:layout_width="30dp"></ImageView>
</LinearLayout>
这里是什么,我有一个屏幕(冲空间已被删除):
如果您有任何想法来解决这个问题(当我用背景图像设计我的布局时,我经常会遇到这种情况),那会很棒。
在此先感谢。
编辑:
这里九宫PNG:
是的,我认为太第一个解决方案,但它是一种技巧,所以它不能解决一般问题,所以我想知道是否存在另一种解决方案。由于这个小三角形,第二个解决方案对于气球来说并不好。但是,如果在接受您的解决方案之前还有其他答案,我会等待。 – Astrorvald
你能上传9贴片图片吗? – AZ13
我用一个工作解决方案编辑了我的答案。 – AZ13