小编Lea*_*Lea的帖子

Android 2.2点击并拖动触摸下居中的图像

我试图将十字准线拖放到一个MapView.我ImageView屏幕上有一个按钮.当我触摸它时,按钮消失并ImageView出现一个新的按钮.新ImageView的应该坐在我的手指中心,直到我在某处释放,但由于某种原因,偏移是不正确的.十字线出现在我触摸的右下方.

所以我相信这个问题是与图像不按比例移动offset_xoffset_y我定义的ACTION_DOWN部分.然后,ACTION_UP我需要createMarker(x,y)在我的手指下的正确坐标,但也错误地偏移.

我尝试了各种方法使其居中,有些方法比其他方法更好.到目前为止,我还没有使用魔术数字使其无法正常工作.

实际上,我使用点击位置并减去图片大小的一半.这对我来说很有意义.如果我减去整个图片大小,它就更接近正确.我已经尝试过网上的各种例子,所有这些例子都受到View位置不准确的影响.

你能给我一些建议吗?

crosshair = (ImageView)findViewById(R.id.crosshair);
frameLayout = (FrameLayout)findViewById(R.id.mapframe);
params = new LayoutParams(LayoutParams.WRAP_CONTENT,
        LayoutParams.WRAP_CONTENT);
crosshairImage = BitmapFactory.decodeResource(getResources(), R.drawable.crosshair);
crosshair.setOnTouchListener(new OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            dragStatus = START_DRAGGING;

            // hide the button and grab a mobile crosshair
            v.setVisibility(View.INVISIBLE);
            image = new ImageView(getBaseContext());
            image.setImageBitmap(crosshairImage);

            // set the image offsets to …
Run Code Online (Sandbox Code Playgroud)

android android-maps

9
推荐指数
1
解决办法
942
查看次数

禁用整个Redactor.js WYSIWYG编辑器

就像你可以禁用一个<textarea disabled>...</textarea>组件,我想禁用一个编辑器编辑器,但仍然在我的页面上显示它.

我希望Redactor能够读取我正在初始化的textarea上的disabled属性,并根据需要禁用编辑器,但它不起作用,而是创建一个功能齐全的编辑器.

<textarea class="redactor" disabled></textarea>
...
<script type="text/javascript">
$(function () {
        $('.redactor').redactor();
});
</script>
Run Code Online (Sandbox Code Playgroud)

是否有其他API命令或解决方法可用于创建禁用的编辑器?一种简单的禁用和启用它的方法将是首选.我似乎无法在Redactor文档或API中找到有关如何执行此操作的任何内容.

我正在使用Redactor 9.1.9,但如果有必要,我愿意升级.谢谢!

jquery redactor redactor.js

6
推荐指数
1
解决办法
2706
查看次数

标签 统计

android ×1

android-maps ×1

jquery ×1

redactor ×1

redactor.js ×1