android-jetpack-compose

Jetpack Compose Canvas BlendMode.SRC_IN makes even background transparent

浪尽此生 提交于 2021-01-29 08:12:52
问题 I'm trying to add an overlay color on top of a PNG image (with a transparent background) using BlendMode.SRC_IN but the background becomes black instead of the set background color as if masking out the background pixels as well. @Composable fun Icon( fraction: Float, image: ImageAsset, defaultColor: Color = Color(0xFFEEEEEE), progressColor: Color = Color(0xFF888888), size: Dp = image.width.dp ) { Box(modifier = Modifier.size(size = size)) { Canvas(modifier = Modifier.fillMaxSize()) {

Adding buildFeatures { compose true } causes build to take indefinitely. How to investigate issue?

五迷三道 提交于 2021-01-29 06:17:49
问题 After having a good experience with Jetpack Compose in new projects I decided to add Compose to an existing project of my company. After making all the necessary changes and writing the first lines of compose code I tried to build the project for the first time. Unfortunately, the build process gets stuck during ui:compileDebugKotlin multiple times (I waited for almost 45m and then stopped the build). I never got any error message, all I could conclude is, that the problem arises after adding

Properly Scoping ViewModel Across Screens

余生长醉 提交于 2021-01-05 07:20:10
问题 Let's say we have a signup form which span multiple screens such as: So I created a Scoped ViewModel spanning across these screens: The problem is that since the state is scoped across screens, going: PersonalInfo Screen -> Set Username Screen -> (pressed back) Personal Info Screen make it like this: Notice that the username state is retained (since the ViewModel is scoped across the whole flow). So when the user goes back to Set Username Screen instead of a blank state, it retains the

Properly Scoping ViewModel Across Screens

六眼飞鱼酱① 提交于 2021-01-05 07:19:24
问题 Let's say we have a signup form which span multiple screens such as: So I created a Scoped ViewModel spanning across these screens: The problem is that since the state is scoped across screens, going: PersonalInfo Screen -> Set Username Screen -> (pressed back) Personal Info Screen make it like this: Notice that the username state is retained (since the ViewModel is scoped across the whole flow). So when the user goes back to Set Username Screen instead of a blank state, it retains the

Jetpack Compose dev06 setContent() doesn't work?

旧街凉风 提交于 2020-12-29 10:40:07
问题 While updating to dev06 and ran the app I got the following error: java.lang.NoSuchMethodError: No static method setContent(Landroid/app/Activity;Lkotlin/jvm/functions/Function0;)Landroidx/compose/Composition; in class Landroidx/ui/core/WrapperKt; or its super classes (declaration of 'androidx.ui.core.WrapperKt' appears in /data/app/tt.reducto.composesample-BYNjMDWbVhiprnPCNJw0LA==/base.apk) 回答1: If you're coming from dev05, dev04 (or less), there's a migration needed. I manage to make it

background color on Button in Jetpack Compose

假装没事ソ 提交于 2020-12-15 03:42:41
问题 Button(backgroundColor = Color.Yellow) { Row { Image(asset = image) Spacer(4.dp) Text("Button") } } I can not figure out why I can't use background color on Button I followed on Compose Layout codelabs there is a problem in backgroundColor and asset in Image(). Please help me figure out how to use Buton, I'm still new 回答1: The backgroundColor for Button no longer work in 1.0.0-alpha7 Use the below instead Button( onClick = {}, colors = ButtonConstants.defaultButtonColors(backgroundColor =

Can Jetpack Compose be used to build App Widgets?

三世轮回 提交于 2020-12-09 16:36:05
问题 With swift, widgets can be written using SwiftUI, but I have not seen any statements regarding whether Jetpack Compose can be used to build Android App Widgets. Is there any information where I can see how that can be done now that Compose is in Alpha? 回答1: That depends a lot on what you mean by "Jetpack Compose". We were discussing this just yesterday on Kotlinlang Slack. If you mean Compose UI and related packages — the library of composables that we can use to build the UIs displayed by

Can Jetpack Compose be used to build App Widgets?

血红的双手。 提交于 2020-12-09 16:33:49
问题 With swift, widgets can be written using SwiftUI, but I have not seen any statements regarding whether Jetpack Compose can be used to build Android App Widgets. Is there any information where I can see how that can be done now that Compose is in Alpha? 回答1: That depends a lot on what you mean by "Jetpack Compose". We were discussing this just yesterday on Kotlinlang Slack. If you mean Compose UI and related packages — the library of composables that we can use to build the UIs displayed by

Can Jetpack Compose be used to build App Widgets?

一个人想着一个人 提交于 2020-12-09 16:27:07
问题 With swift, widgets can be written using SwiftUI, but I have not seen any statements regarding whether Jetpack Compose can be used to build Android App Widgets. Is there any information where I can see how that can be done now that Compose is in Alpha? 回答1: That depends a lot on what you mean by "Jetpack Compose". We were discussing this just yesterday on Kotlinlang Slack. If you mean Compose UI and related packages — the library of composables that we can use to build the UIs displayed by

Type 'State<List<User>?>' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate

我的未来我决定 提交于 2020-12-08 07:27:55
问题 I'm trying to get a value from LiveData with observeAsState in jetpack compose, but I get a weird error Type 'State<List?>' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate Code @Composable fun UserScreen(userViewModel:UserViewModel){ val items: List<User> by userViewModel.fetchUserList.observeAsState() UserList(userList = items) } ViewModel class UserViewModel: ViewModel() { private val dataSource = UserDataSource() val fetchUserList = liveData { emit