android控件布局自动自适应屏幕

使用ConstraintLayout布局,子控件添加如下属性

app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.92"
app:layout_constraintWidth_percent="0.23"
app:layout_constraintVertical_bias="0.53"
app:layout_constraintHeight_percent="0.55"
app:layout_constraintHorizontal_weight="0"

大小位置,包括字体大小,根据屏幕大小完美自适应,想放哪放哪,想多大多大,吼吼

参数就是百分比。

最后的字体写0,或者你用代码再改成想要的大小

猜你喜欢

转载自www.cnblogs.com/litandy2016/p/11910472.html