磐安县住和城乡建设局网站,可以打开任何网站的软件,默认开启评论 wordpress,邻水网站建设AutoScalingLayout
适用于 Android 的自动缩放布局。 替换布局#xff1a;
我们只需要替换根布局所需的自动缩放#xff0c;子布局也将实现自动缩放。
原始布局AutoScalingLayout相对布局ASRelativeLayout线性布局ASLinearLayoutFrameLayout#xff08;框架布局#xff…AutoScalingLayout
适用于 Android 的自动缩放布局。 替换布局
我们只需要替换根布局所需的自动缩放子布局也将实现自动缩放。
原始布局AutoScalingLayout相对布局ASRelativeLayout线性布局ASLinearLayoutFrameLayout框架布局ASFrameLayout
目前支持上述三种布局。
添加属性
designWidth 和 designHeight 是在 xml 编辑器中设计 GUI 时使用的屏幕大小。例如我使用 平板的xml因此转换为 dp 的通用屏幕尺寸为 1280dp 和 720dp不包括状态栏和操作栏。
autoScaleEnable 用于启用/禁用缩放。
autoScaleType 可以是“fitInside”、“fitWidth”和“fitHeight”
me.dreamheart.autoscalinglayout.ASLinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsxmlns:customhttp://schemas.android.com/apk/res-autocustom:designWidth1280dpcustom:designHeight720dpcustom:autoScaleEnabletruecustom:autoScaleTypefitInsideandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:backgrounddrawable/ic_bgandroid:orientationverticaltools:context.MainActivity
designWidth 和 designHeight 非常重要。如果分配了错误的值则不会看到预期的布局。xml GUI 编辑器中使用的单位应保持不变。例如如果将 dp 用于 designWidth 和 designHeight则子视图的所有单位都必须是 dp甚至字体大小也不能是 sp因此为 px、pt。如果您只想复制 GUI 给出的像素值只需对所有组件使用 px 即可。应用 AutoScalingLayout 时屏幕将保持 designWidth 和 designHeight 的纵横比因此不必担心将方形布局意外转换为矩形。
参考如下
项目概览 - AutoScalingLayout - GitCode