Questions tagged [android-jetpack]

Android Jetpack is a Google's set of libraries, tools and architectural guidance to build Android apps and provides common infrastructure code.

Android Jetpack is the next generation of Android components, bringing together the benefits of the Support Library -- backwards compatibility and immediate updates -- to a larger set of components, making it quick and easy to build robust, high quality apps.

It manages activities like background tasks, navigation, and lifecycle management, so you can eliminate boilerplate code and focus on what makes your app great.

It is designed to work well with Kotlin, saving you even more code with Android KTX. The new Android Jetpack components released today include WorkManager, Paging, Navigation, and Slices.

Useful Links

2879 questions
68
votes
10 answers

how to instantiate ViewModel In AndroidX?

I want to initialize ViewModel in Activity using androidx library I have tried what documentation says but it is not working. the ".of" is not resolved. import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import…
64
votes
3 answers

How to show ellipsis (three dots) at the end of a Text line in Android Jetpack Compose?

Whether I use androidx.compose.foundation.text.BasicText or androidx.compose.material.Text, if there isn't enough space for a text it wraps to the next line, for example: @Composable fun EllipsisExample() { Box(modifier = Modifier.width(160.dp))…
Valeriy Katkov
  • 33,616
  • 20
  • 100
  • 123
64
votes
1 answer

Android Work Manager vs Services?

In my Android app i have multiple intent services which run one after another and the very first intent service is trigerred by a broadcast. I came across Work Manager a few days ago and really liked the simplicity of the Worker and the WorkManager…
Dishonered
  • 8,449
  • 9
  • 37
  • 50
61
votes
2 answers

How to convert Dp to pixels in Android Jetpack Compose?

Most of Jetpack Compose API uses Dp as a dimensions unit, but sometimes a pixel value is required. How can I convert a dp value to px? Just for an example there's graphicsLayer() modifier that accepts translationX/Y arguments in pixels.
Valeriy Katkov
  • 33,616
  • 20
  • 100
  • 123
60
votes
4 answers

Android Jetpack compose gradient

Is it possible to draw a gradient over an image drawable using Jetpack Compose? fun HeroCover() { Column { val image = +imageResource(R.drawable.edge_of_tomorrow_poster) Container(modifier = Height(440.dp) wraps Expanded) { …
AouledIssa
  • 2,528
  • 2
  • 22
  • 39
58
votes
9 answers

Show custom alert dialog in Jetpack Compose

I am searching how create custom dialog in Jetpack Compose. In XML or Material Design we can create easily custom Dialog in which we can take user input, radio button etc. but i am not finding such thing in Jetpack Compose.
57
votes
6 answers

How do I define default animations for Navigation Actions?

I'm using Android Studio 3.2 Canary 14 and The Navigation Architecture Component. With this you can define transition animations pretty much as you would when using Intents. But the animations are set as properties of the actions in the navigation…
54
votes
4 answers

How to use string resources in Android Jetpack Compose?

Let's I have the following strings.xml resource file: My Playground Hello %!