Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
376 views
in Technique[技术] by (71.8m points)

Android Jetpack Compose: All row items not rendering on smaller screens

I'm still getting the hang of Android's Jetpack Compose declarative UI library and would appreciate some help. The column (containing an image "icon" and text) isn't rendering at all on smaller screens. Here is the relevant code -->

@Composable
fun ComposableExample() {
...
ScrollableColumn(modifier = Modifier.fillMaxWidth()) {
    // Scrollable column should have one child.
    Column {
        
        Row(
            modifier = Modifier.fillMaxWidth(),
            verticalAlignment = Alignment.CenterVertically,
        ) {
            
            Text(text = "This is the Title of the Video")
            
            //--------- This column is rendering on wider (tablet+) screens but not phone sized screens.
            Column(horizontalAlignment = Alignment.CenterHorizontally,
                modifier = Modifier.fillMaxWidth()) {
                Image(imageResource(id = R.drawable.icon_download_arrow),
                    modifier = Modifier.preferredSize(20.dp)
                        .clickable(onClick = { }))
                Text(text = "Download")
            }
            // ---------
            
        }
            ...
    }
}
}

I've tried a ton of different modifiers/permutations and can't get the column to render on smaller screens. I'd really appreciate some help, thanks!

question from:https://stackoverflow.com/questions/65875034/android-jetpack-compose-all-row-items-not-rendering-on-smaller-screens

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Simply swapping the column and the text is working, i.e. rendering the the clickable column of icon image and text BEFORE the video title. Not entirely sure why this is working, but it is!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...