MOBILEPROGLIB Telegram 6239
✂️ Обрезка в Jetpack Compose

Обрезка — это удаление частей контента за пределами заданной формы. Представьте, что вы используете формочки для печенья: всё, что находится внутри формочки, остаётся, а всё, что снаружи, удаляется.

В Compose это делается с помощью Modifier.clip функции:

Image(
painter = painterResource(R.drawable.avatar),
contentDescription = null,
modifier = Modifier
.size(72.dp)
.clip(CircleShape)
)


Здесь изображение обрезается по кругу, независимо от фактических границ растрового изображения.

📌 Пользовательские Формы

Если встроенных фигур (CircleShape, RoundedCornerShape и т. д.) недостаточно, вы можете создать собственную Shape и нарисовать свой собственный контур. Например:

class SquishedOvalShape : Shape {
override fun createOutline(
size: Size,
layoutDirection: LayoutDirection,
density: Density
): Outline {
return Outline.Generic(
Path().apply {
addOval(Rect(0f, size.height / 4f, size.width, size.height))
}
)
}
}


Примените его, как и любую другую форму:

Modifier.clip(SquishedOvalShape())


🐸 Библиотека мобильного разработчика

#PixelPerfect #MiddlePath #Android
Please open Telegram to view this post
VIEW IN TELEGRAM
2



tgoop.com/mobileproglib/6239
Create:
Last Update:

✂️ Обрезка в Jetpack Compose

Обрезка — это удаление частей контента за пределами заданной формы. Представьте, что вы используете формочки для печенья: всё, что находится внутри формочки, остаётся, а всё, что снаружи, удаляется.

В Compose это делается с помощью Modifier.clip функции:

Image(
painter = painterResource(R.drawable.avatar),
contentDescription = null,
modifier = Modifier
.size(72.dp)
.clip(CircleShape)
)


Здесь изображение обрезается по кругу, независимо от фактических границ растрового изображения.

📌 Пользовательские Формы

Если встроенных фигур (CircleShape, RoundedCornerShape и т. д.) недостаточно, вы можете создать собственную Shape и нарисовать свой собственный контур. Например:

class SquishedOvalShape : Shape {
override fun createOutline(
size: Size,
layoutDirection: LayoutDirection,
density: Density
): Outline {
return Outline.Generic(
Path().apply {
addOval(Rect(0f, size.height / 4f, size.width, size.height))
}
)
}
}


Примените его, как и любую другую форму:

Modifier.clip(SquishedOvalShape())


🐸 Библиотека мобильного разработчика

#PixelPerfect #MiddlePath #Android

BY Библиотека мобильного разработчика | Android, iOS, Swift, Retrofit, Moshi, Chuck


Share with your friend now:
tgoop.com/mobileproglib/6239

View MORE
Open in Telegram


Telegram News

Date: |

The main design elements of your Telegram channel include a name, bio (brief description), and avatar. Your bio should be: Public channels are public to the internet, regardless of whether or not they are subscribed. A public channel is displayed in search results and has a short address (link). The visual aspect of channels is very critical. In fact, design is the first thing that a potential subscriber pays attention to, even though unconsciously. When choosing the right name for your Telegram channel, use the language of your target audience. The name must sum up the essence of your channel in 1-3 words. If you’re planning to expand your Telegram audience, it makes sense to incorporate keywords into your name. The creator of the channel becomes its administrator by default. If you need help managing your channel, you can add more administrators from your subscriber base. You can provide each admin with limited or full rights to manage the channel. For example, you can allow an administrator to publish and edit content while withholding the right to add new subscribers.
from us


Telegram Библиотека мобильного разработчика | Android, iOS, Swift, Retrofit, Moshi, Chuck
FROM American