IceDimen

This is a useful library for Android to fit screen.

Лицензия

Лицензия

Группа

Группа

com.github.icebuf
Идентификатор

Идентификатор

icedimen
Последняя версия

Последняя версия

0.0.1
Дата

Дата

Тип

Тип

aar
Описание

Описание

IceDimen
This is a useful library for Android to fit screen.
Ссылка на сайт

Ссылка на сайт

https://github.com/icebuf/IceDimen
Система контроля версий

Система контроля версий

https://github.com/icebuf/IceDimen.git

Скачать icedimen

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.icebuf/icedimen/ -->
<dependency>
    <groupId>com.github.icebuf</groupId>
    <artifactId>icedimen</artifactId>
    <version>0.0.1</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.icebuf/icedimen/
implementation 'com.github.icebuf:icedimen:0.0.1'
// https://jarcasting.com/artifacts/com.github.icebuf/icedimen/
implementation ("com.github.icebuf:icedimen:0.0.1")
'com.github.icebuf:icedimen:aar:0.0.1'
<dependency org="com.github.icebuf" name="icedimen" rev="0.0.1">
  <artifact name="icedimen" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.github.icebuf', module='icedimen', version='0.0.1')
)
libraryDependencies += "com.github.icebuf" % "icedimen" % "0.0.1"
[com.github.icebuf/icedimen "0.0.1"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

GitHub release (latest by date) GitHub code size in bytes Gitlab pipeline status GitHub

IceDimen

控件按比例适配

有时候我们需要在Android到dimens资源文件中定义一个dimen声明表示一个控件 到长度或宽度,通过不同dpi的dimens资源文件的声明可以适配多种不同dpi的屏幕

IceDimen提供了已经创建好的不同dpi的dimens资源文件,这些文件种的dimen声明均采用比例缩放 可以实现当屏幕分布率不变时,在不同dpi的屏幕上显示比例相同的控件

参考比例:

DPI ldpi mdpi hdpi xhdpi xxhdpi xxxhdpi
数值 120 160 240 320 480 640
缩放比例 0.75 1 1.5 2 3 4
icon尺寸 18x18 24x24 32x32 48x48 72x72 96x96

依赖导入:

    implementation 'com.github.icebuf:icedimen:0.0.1'

在xml种使用:

<TextView
    android:layout_width="@dimen/dpi_120px"
    android:layout_height="@dimen/dpi_48px">
    
</TextView>

在代码种使用:

public class SampleDimen {
    public void test() {
        float width = getResources().getDimension(R.dimen.dpi_2160px);
    }
}

不同分辨率尺寸下的截图

  • Phone 1080p xxhdpi

phone_1080p_xxhdpi

  • Phone 1440p xxxhdpi

phone_1440p_xxxhdpi

  • Tablet 1200x1920 xhdpi

Tablet_1200x1920_xhdpi

  • Tablet 2048x1536 xhdpi

Tablet_2048x1536_xhdpi

  • Tablet 2560x1600 xhdpi

tablet_2560x1600_xhdpi

  • TV 1080p xhdpi

tv_1920x1080_xhdpi

Версии библиотеки

Версия
0.0.1