问题描述
我能做出一个完全定制ViewLabel在Android中nutiteq,定义版面设计和尺寸。然而,可点击视图不会按预期工作。首先,我试图通过定义根布局点击使整个标签点击,但这并没有工作。添加一个按钮也不起作用。这怎么解决?
I am able to make a fully customized ViewLabel in Android nutiteq, defining layout design and sizes. However, clickable Views are not working as expected. First I tried to make the whole label clickable by defining the root layout as clickable, but this didn't work. Adding a Button too does not work. How can this problem be solved?
MapPos markerLoc = rasterLayer.getProjection().fromWgs84(lng, lat);
Marker marker;
CustomPOILayout layout = new CustomPOILayout(this);
layout.setTitle((poi.title.trim().length() == 0)? "kein Titel" : poi.title);
layout.setDescription((poi.desc.trim().length() == 0)? "keine Beschreibung" : poi.desc);
layout.setDateAndAuthor(COSAHelper.convertTimestamp(poi.resCreated) + "\nvon: " + poi.author);
layout.setImages(poi.byteStrings);
layout.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
layout.layout(0, 0, layout.getMeasuredWidth(), layout.getMeasuredHeight());
Label label = new ViewLabel("", layout,
new Handler(),
LabelStyle.builder()
.setAlpha(1.0f)
.setBorderRadius(0)
.setBorderColor(Color.GRAY)
.setBorderWidth(5)
.build()
);
marker = new Marker(markerLoc, label, markerStyle3, markerLayer);
markerLayer.add(marker);
在XML布局
<TextView
android:id="@+id/label_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textStyle="bold"
/>
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="@color/abc_search_url_text_normal"
/>
<TextView
android:id="@+id/label_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="11sp"
/>
<TextView
android:id="@+id/label_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
/>
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="@color/abc_search_url_text_normal"
/>
<LinearLayout
android:id="@+id/label_container1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:layout_margin="5dip"
android:minHeight="25dip"
/>
<ImageView
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:layout_margin="5dip"
android:minHeight="25dip"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/label_container2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:layout_margin="5dip"
android:minHeight="25dip"
/>
<ImageView
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:layout_margin="5dip"
android:minHeight="25dip"
/>
</LinearLayout>
<TextView
android:id="@+id/label_text_images"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
/>
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="@color/abc_search_url_text_normal"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="zeige Ressource"
android:gravity="center"
android:onClick="onClickTest"
android:layout_gravity="center"
android:textSize="14sp"/>
推荐答案
如果我理解正确的话,你希望所有点击转发到标签内的看法? ViewLabel 有方法的: setTouchHandlingMode 。只需拨打 viewLabel.setTouchHandlingMode(真)
If I understand correctly, you want all clicks to be forwarded to the view inside the label? ViewLabel has method for this: setTouchHandlingMode. Simply call viewLabel.setTouchHandlingMode(true).
这篇关于nutiteq:按钮RESP。点击查看未在自定义ViewLabel工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!