Questions tagged [android-jetpack-compose]
Jetpack Compose is Android’s modern toolkit for building native declarative UI made by Google. If you're targeting desktop with Compose for Desktop, use both this and [compose-desktop] tags.
android-jetpack-compose
13,181
questions
198
votes
12
answers
131k
views
How to get Context in Jetpack Compose
fun createListItem(itemIndex: Int) {
Padding(left = 8.dp, right = 8.dp, top = 8.dp, bottom = 8.dp) {
FlexRow(crossAxisAlignment = CrossAxisAlignment.Center) {
expanded(1.0f) {
...
186
votes
13
answers
60k
views
Type 'State<List<User>?>' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate
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 ...
183
votes
9
answers
132k
views
How to add Margin in Jetpack Compose?
How exactly can you add Margin in Jetpack Compose?
I can see that there is a Modifier for padding with Modifier.padding(...) but I can't seem to find one for margins or am I blind?
Someone guide me ...
175
votes
19
answers
243k
views
Jetpack Compose - Column - Gravity center
I'm creating a layout with Jetpack Compose and there is a column. I would like center items inside this column:
Column(modifier = ExpandedWidth) {
Text(text = item.title)
Text(text = ...
165
votes
25
answers
136k
views
Hilt Unsupported metadata version in Kotlin
I was tried to run my code in Kotlin 1.5.10
With plugin as
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
and dependencies as below
...
137
votes
11
answers
73k
views
How to disable ripple effect when clicking in Jetpack Compose
In Jetpack Compose, when you enable clickable {} on a modifier for a composable, by default it enables ripple effect for it. How to disable this behavior?
Example code
Row(modifier = Modifier
...
129
votes
10
answers
71k
views
How to close the virtual keyboard from a Jetpack Compose TextField?
I'm using the Jetpack Compose TextField and I want to close the virtual keyboard when the user press the the action button (imeActionPerformed parameter).
val text = +state { "" }
TextField(
...
122
votes
7
answers
39k
views
Content padding parameter it is not used
I recently started working with Jetpack Compose. I've got the following composable:
@Composable
fun SearchScreen(navController: NavHostController) {
Scaffold(
topBar = { SearchBar() },
...
120
votes
12
answers
145k
views
How to load Image from drawable in Jetpack compose?
I have tried below code but it reflects nothing in the UI, I'm missing anything here?
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
...
118
votes
6
answers
93k
views
Screen width and height in Jetpack Compose
I am wondering how to get the screen width and height with Jetpack Compose?
Is there any way you can retrieve the screen dimensions other than
getWindowManager().getDefaultDisplay()?
113
votes
5
answers
81k
views
How to use Compose inside Fragment?
The documentation describes how to create UI Jetpack Compose inside Activity.
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(...
111
votes
4
answers
63k
views
Android Jetpack Compose Icons doesn't contain some of the material icons
There're many oft-used material icons in androidx.compose.material.icons.Icons but some are missing. Just as an example there is no print icon.
...
import androidx.compose.material.Icon
import ...
111
votes
7
answers
74k
views
Request Focus on TextField in jetpack compose
How to auto focus on textfield in jetpack compose. When i click on textfield and start typing on it. Meantime when i click back button,then when i'm try to click on textfield, nothing happens.
val ...
103
votes
14
answers
29k
views
Jetpack compose can't preview after updating to 1.0.0-rc01
this happened to me only when I updated to 1.0.0-rc01.
it says:
The following classes could not be found:
- androidx.compose.ui.tooling.preview.ComposeViewAdapter (Fix Build Path, Edit XML, Create ...
101
votes
17
answers
57k
views
Jetpack Compose Text hyperlink some section of the text
How can i add hyperlink to some section of the text of Text component?
With buildAnnotatedString i can set link section blue and underlined as in image below, but how can i also turn that section ...