Skip to content

Broken button child width on Android #4324

@zvonimirr

Description

@zvonimirr

Current behaviour

I have a button with a child that is a View with the following style.

{
    width: "100%",
    flexDirection: "row",
    alignItems: "center",
    justifyContent: "space-between",
}

On iOS it works without any issues, however on Android it seems to be having a bit of trouble.

Expected behaviour

I expect both platform to honor the width: "100%", and fill the entire button.

How to reproduce?

<Button>
  <View style={{
    width: "100%",
    flexDirection: "row",
    alignItems: "center",
    justifyContent: "space-between",
  }}>
    <Icon1 />
    <Text>
      View All Transactions
    </Text>
    <Icon2 />
  </View>
</Button>

Preview

Screenshot 2024-02-26 at 16 57 44

Added the extra background color for clarity.

What have you tried so far?

I tried experimenting with onLayout prop, but in the end just ended up hardcoding the padding on the Text element inside the View.

Your Environment

software version
ios 17.0.1
android 13
react-native 0.73.4
react-native-paper 5.12.3
node 20.5.0
npm or yarn 10.2.5
expo sdk 50.0.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions