locked
AutocompleteBar Control RRS feed

  • Question

  • User371569 posted

    I'm attempting to make a control for an Autocomplete Bar and I thought I had it as it works perfect on iOS but not so on Android. Within my control, I'm trying to put a rounded Frame behind the SearchBar to give it a rounded look, shadow, etc. and my code works fine on iOS but on Android the Frame overlays the search bar no matter what I try. I can't explicitly define the Z axis coordinates anywhere from the look of it as it's supposed to be implicit in the order but that doesn't seem to be working. Code posted below:

            <Grid Margin="6" Grid.Row="0" Grid.Column="0">
                <Frame BackgroundColor="{StaticResource ColorCard}"
                      CornerRadius="16" BorderColor="{StaticResource ColorTextPrimary}" />
    
                <SearchBar x:Name="mSearchBar" BackgroundColor="Transparent"
                     Placeholder="Search" PlaceholderColor="{StaticResource ColorTextSecondary}"
                     TextColor="{StaticResource ColorTextPrimary}"
                     SearchButtonPressed="Handle_SearchButtonPressed"
                     TextChanged="Handle_TextChanged" />    
            </Grid>
    
    Friday, August 3, 2018 3:43 PM

Answers

  • User21936 posted

    @dan1229

    I believe this is a known issue on Android v24 (Nougat). See this discussion: https://forums.xamarin.com/discussion/79446/is-there-support-for-searchbar-on-nougat-7-0

    So try adding a HeightRequest to your SearchBar. And further, the Frame should contain your searchbar, e.g.:

    <Grid Margin="6" Grid.Row="0" Grid.Column="0">
            <Frame BackgroundColor="Aqua"
                  CornerRadius="16" BorderColor="Red" >
             <SearchBar x:Name="mSearchBar" BackgroundColor="Transparent"
                 Placeholder="Search" PlaceholderColor="Gray"
                 TextColor="Black"
                 SearchButtonPressed="Handle_SearchButtonPressed"
                 TextChanged="Handle_TextChanged" HeightRequest="50"/>                  
            </Frame>
        </Grid>
    
    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, August 14, 2018 2:16 AM