0

ボタンを中心点=タッチポイントで膨らませたい。膨らませるとき、m は次のようにします。

control = inflater.inflate(R.layout.button,
                    (ViewGroup) target_layout, false);
targetContainer.addView(control);

    x = x - (control.getWidth()/2);   // control not inflating exactly @ center of 
    y = y - (control.getHeight()/2); //  the touch left.
    absoluteLayoutParams = new AbsoluteLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT, x, y);
    control.setLayoutParams(absoluteLayoutParams);

button.xmlには、高さと幅 = ラップ コンテンツのボタンが含まれています。 ここのx & yは、ドラッグをリリースしたときのタッチ座標です。


このように膨らみますこれは、タッチポイントから膨らむ方法です。

このくらい膨らむと思いますタッチポイントからこのように膨らむと思います。

よろしくお願いします、カピル。

4

1 に答える 1

0

電話してみる

targetContainer.addView(control); 

layoutParams を設定すると、次のようになります。

control = inflater.inflate(R.layout.button,
                (ViewGroup) target_layout, false);

x = x - (control.getWidth()/2);   // control not inflating exactly @ center of 
y = y - (control.getHeight()/2); //  the touch left.
absoluteLayoutParams = new AbsoluteLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT, x, y);
control.setLayoutParams(absoluteLayoutParams);

targetContainer.addView(control);

多分それが問題です。

于 2012-12-12T08:56:27.727 に答える