[2.15.0] fix bug of custom pnc action view

This commit is contained in:
zhongchao
2023-04-18 10:12:45 +08:00
parent 0682db383f
commit 6896faa698

View File

@@ -44,8 +44,8 @@ class PncActionsView @JvmOverloads constructor(
private var mAutoPilotStatusInfo: AutopilotStatusInfo? = null
private val bgResources: Int
private val topMargin: Int
private val txtSize: Int
private val topMargin: Float
private val txtSize: Float
init {
LayoutInflater.from(context).inflate(R.layout.view_pnc_actions, this, true)
@@ -54,21 +54,21 @@ class PncActionsView @JvmOverloads constructor(
R.styleable.PncActionsView_background_resource,
R.drawable.pnc_actions_bg
)
topMargin = a.getResourceId(
topMargin = a.getDimension(
R.styleable.PncActionsView_pnc_top_margin,
resources.getDimension(R.dimen.dp_30).toInt()
resources.getDimension(R.dimen.dp_30)
)
txtSize = a.getResourceId(
txtSize = a.getDimension(
R.styleable.PncActionsView_pnc_size,
resources.getDimension(R.dimen.dp_34).toInt()
resources.getDimension(R.dimen.dp_34)
)
a.recycle()
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
(tvHmiPncActions.layoutParams as MarginLayoutParams).topMargin = topMargin
tvHmiPncActions.setTextSize(COMPLEX_UNIT_PX, txtSize.toFloat())
(tvHmiPncActions.layoutParams as MarginLayoutParams).topMargin = topMargin.toInt()
tvHmiPncActions.setTextSize(COMPLEX_UNIT_PX, txtSize)
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
CallerPlanningActionsListenerManager.addListener(TAG, this)