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: |

There have been several contributions to the group with members posting voice notes of screaming, yelling, groaning, and wailing in different rhythms and pitches. Calling out the “degenerate” community or the crypto obsessives that engage in high-risk trading, Co-founder of NFT renting protocol Rentable World emiliano.eth shared this group on his Twitter. He wrote: “hey degen, are you stressed? Just let it out all out. Voice only tg channel for screaming”. During the meeting with TSE Minister Edson Fachin, Perekopsky also mentioned the TSE channel on the platform as one of the firm's key success stories. Launched as part of the company's commitments to tackle the spread of fake news in Brazil, the verified channel has attracted more than 184,000 members in less than a month. Developing social channels based on exchanging a single message isn’t exactly new, of course. Back in 2014, the “Yo” app was launched with the sole purpose of enabling users to send each other the greeting “Yo.” The optimal dimension of the avatar on Telegram is 512px by 512px, and it’s recommended to use PNG format to deliver an unpixelated avatar. How to create a business channel on Telegram? (Tutorial)
from us


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