那些奇奇怪怪的问题
ConstraintLayout 预览显示不了
不止ConstraintLayout,还有其他的 androidx 的问题,其实很诡异,上午没事下午就预览不了了,结果更新版本解决了
,看到日志是 class 类有问题 样式加载不了
TextView 换行不生效,inputType导致
第一天正式写ConstraintLayout,遇到问题就把问题想成了 ConstraintLayout 中的TextView 换行问题? 最后发现是 inputType 的问题,加了之后就限制为了一行。
自定义 Switch
用的是 thumb 和 track 手指和轨道的意思
BottomSheetDialogFragment的阴影和高度
解决阴影问题 android:elevation=“0dp”
高度问题 kotlin 代码
下面展示一些 内联代码片
。
override fun onStart() {
super.onStart()
val dialog = dialog as BottomSheetDialog
if (dialog != null) {
val bottomSheet = dialog.delegate.findViewById<View>(com.google.android.material.R.id.design_bottom_sheet)
bottomSheet!!.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT //自定义高度
}
val view = view
view!!.post {
val parent = view.parent as View
val params = parent.layoutParams as CoordinatorLayout.LayoutParams
val behavior = params.behavior
val bottomSheetBehavior = behavior as BottomSheetBehavior<*>?
bottomSheetBehavior!!.peekHeight = view.measuredHeight
}
Kotlin 的 findviewById
apply plugin: ‘com.android.application’
apply plugin: ‘kotlin-android’
apply plugin: ‘kotlin-android-extensions’
import kotlinx.android.synthetic.main.activity_main.*
ConstrainLayout 一些奇怪的居中
1 是 可以用等分线 辅助线
2 是用约束链
app:layout_constraintHorizontal_chainStyle=“packed”
mothionLayout 在 alpha—3 版本 报空指针
1 用子类实例化完成 完成空指针的方法
2 换回 2
3 xml 上有个属性加上 app:layoutDescription="@xml/***"
过渡动画
val rootView: ViewGroup = findViewById(R.id.root)
TransitionManager.beginDelayedTransition(rootView)
val consset = ConstraintSet()
if (changgeBoolean) {
consset.clone(this, R.layout.activity_main)
} else {
consset.clone(this, R.layout.activity_main1)
}
consset.applyTo(rootView as ConstraintLayout?)
changgeBoolean = !changgeBoolean