添加缩放控制到正常的XML布局 [英] Adding Zoom Controls to a normal XML layout
问题描述
我只是想知道,是否有可能对我来说,缩放控件添加到我的XML布局。如果是的话,任何人都可以直接我基于它的样本。或基于其上的任何帮助将帮助我很多。谢谢你。
I just want to know, whether it is possible for me to add zoom controls to my XML layout. If yes, can anyone direct me to a sample based on it. Or any help based on it will help me much. Thanks.
推荐答案
只有几个控件(例如web视图和图形页面)都内置了缩放。您需要实现自己的逻辑放大到任何其他视图和/或布局。
Only a few controls (e.g. WebView and MapView) have built-in zoom. You will need to implement your own zoom logic to any other View and/or layout.
如果你只是问的按钮来控制变焦,只需添加以下code到您的布局:
If you are just asking about the buttons to control the zoom, just add the following code to your layout:
<ZoomControls
android:id="zoomControls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
(注意,此code将添加的按钮,但不是任何实际缩放功能)
(note that this code will add the buttons, but not any actual zoom functionality)
检查API 这里。您将需要设置两个侦听这些控件,关于在变焦和一个用于缩小。这些都是标准的 OnClickListener
就像与其他任何按钮。你必须放大/缩小的onClick(视图v)
回调中。
Check the api here. You will need to set up two listeners for those controls, on for zoom in and one for zoom out. Those are standard OnClickListener
s like with any other button. You'll have to zoom in/out inside the onClick(View v)
callback.
这篇关于添加缩放控制到正常的XML布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!