AlertDialog compose title with Image

Viewed 24

In AlertDialog on compose, do you know if its possible in the title field, to put an Image plus a title ?

I am trying to do something like

title = {
    Column(
        modifier = Modifier
            .fillMaxWidth()
    ) {
        Image(
            imageVector = image,
            contentDescription = null,
            modifier = Modifier
                .align(Alignment.CenterHorizontally)
            )
        Text("Title")
    }
},

text = {
    Text("test text")
},

The problem is : I think the title in AlertDialog has a specific size, so my Image is crop.

example

1 Answers

With M3 AlertDialog (androidx.compose.material3.AlertDialog) it works.

enter image description here

With M2 AlertDialog you can remove the title attribute and use the text attribute for the whole layout.

AlertDialog(
    onDismissRequest = {},
    text = {
        Column(Modifier.fillMaxWidth()){
            Image(
                painterResource(id = R.drawable.xxx),
                contentDescription = null,
                modifier = Modifier
                    .align(Alignment.CenterHorizontally)
            )
            Image(
                painterResource(id = R.drawable.xxx),
                contentDescription = null,
                modifier = Modifier
                    .align(Alignment.CenterHorizontally)
            )
            Text("Title")
            //.....
        }
    },
    buttons = {}
)
Related