|
@@ -28,7 +28,6 @@ import android.graphics.*
|
|
|
import android.util.AttributeSet
|
|
|
import android.util.Log
|
|
|
import android.view.*
|
|
|
-import android.view.MotionEvent
|
|
|
import com.sybotan.android.graphy.enums.SGraphyViewTouchState
|
|
|
import com.sybotan.android.graphy.events.SGraphyViewMoveEvent
|
|
|
import com.sybotan.android.graphy.events.SGraphyViewZoomEvent
|
|
@@ -125,6 +124,12 @@ open class SGraphyView(context: Context, attrs: AttributeSet? = null)
|
|
|
initView()
|
|
|
} // init
|
|
|
|
|
|
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
|
|
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
|
|
+ Log.e("w",widthMeasureSpec.toString())
|
|
|
+ Log.e("h",heightMeasureSpec.toString())
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 适配视图到视图
|
|
|
*/
|
|
@@ -133,12 +138,25 @@ open class SGraphyView(context: Context, attrs: AttributeSet? = null)
|
|
|
if (null == scene) {
|
|
|
return
|
|
|
}
|
|
|
+// val w = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)
|
|
|
+// val h = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)
|
|
|
+// this.measure(width, height)
|
|
|
+// val h: Int = this.getMeasuredHeight()
|
|
|
+// val w: Int = this.getMeasuredWidth()
|
|
|
+
|
|
|
+ this.post {
|
|
|
+ val w = width.toFloat()
|
|
|
+ val h = height.toFloat()
|
|
|
+
|
|
|
+ val rect = scene!!.worldRect()
|
|
|
+ setCenterPoint( PointF(rect.centerX(), rect.centerY()),
|
|
|
+ min(w / rect.width(), h / rect.height()) * fitrate)
|
|
|
+// Log.e("w",w.toString())
|
|
|
+// Log.e("h",h.toString())
|
|
|
+// Log.e("rect1",rect.toJson())
|
|
|
+// Log.e("min",(min(w / rect.width(), h / rect.height())).toJson())
|
|
|
+ }
|
|
|
|
|
|
- val w = width.toFloat()
|
|
|
- val h = height.toFloat()
|
|
|
- val rect = scene!!.worldRect()
|
|
|
- setCenterPoint( PointF(rect.centerX(), rect.centerY()),
|
|
|
- min(w / rect.width(), h / rect.height()) * fitrate)
|
|
|
} // Function FitView()
|
|
|
|
|
|
/**
|