Skip to main content

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
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) { ...
Mr. Tayyab MuGhal's user avatar
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 ...
SNM's user avatar
  • 6,355
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 ...
Archie G. Quiñones's user avatar
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 = ...
mac229's user avatar
  • 4,709
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 ...
Lang Minh Nguyên's user avatar
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 ...
ImMathan's user avatar
  • 4,691
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( ...
nglauber's user avatar
  • 22.4k
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() }, ...
BenjyTec's user avatar
  • 6,960
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?) { ...
Maddy's user avatar
  • 4,905
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()?
AbdulMomen عبدالمؤمن's user avatar
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(...
Nurseyit Tursunkulov's user avatar
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 ...
Valeriy Katkov's user avatar
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 ...
Mukul jangir's user avatar
  • 1,211
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 ...
Karim Sinouh's user avatar
  • 1,622
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 ...
Thracian's user avatar
  • 59k

15 30 50 per page
1
2 3 4 5
879