xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

Long text in Label inside StackLayout inside AbsoluteLayout results in a out of container drawing. #7819

Open aubiyko opened 5 years ago

aubiyko commented 5 years ago

Description

Suppose master Label lies inside StackLayout inside AbsoluteLayout. If I change text from short to long in Label it does change size but moves other children to draw outside of container (or container does not resize correctly). Although adding additional children to parent container or changing button size produce correct results.

Steps to Reproduce

  1. Use application from Reproduction Link
  2. Change text to long\short
  3. Add one or more buttons
  4. Enlarge first button

Expected Behavior

Height of Label with multiline text scales its parent container correctly.

Actual Behavior

I don't think it is suppose to work like that.

Basic Information

Screenshots

Android

iOS

Reproduction Link

Application uses color coded visual elements backgrounds with round corners to ease debugging. Github

aubiyko commented 5 years ago

After additional testing, I find out that button also has this issue. I suppose this maybe related? Repro has been updated.

eszterhorvath commented 3 years ago

I have the same issue. The Label is inside a Grid inside a StackLayout inside a ScollView but the same happens also without the ScrollView.

Screenshots

iOS: image

UWP: image

Android: image

<ContentPage.Content>
    <ScrollView VerticalOptions="FillAndExpand" HorizontalOptions="Fill" IsClippedToBounds="true">
        <StackLayout Padding="10" VerticalOptions="FillAndExpand" HorizontalOptions="Fill" IsClippedToBounds="true">
                <Grid Margin="0,10,0,10" BackgroundColor="DarkRed">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="1*"/>
                        <ColumnDefinition Width="1*"/>
                    </Grid.ColumnDefinitions>
                    <Grid Grid.Column="0" BackgroundColor="DeepPink">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="20"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Label Text="Title1" FontAttributes="Bold" Grid.Row="0" BackgroundColor="Yellow"/>
                        <Label Grid.Row="1" Text="The Call of Cthulhu by H. P. Lovecraft The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents. We live on a placid island of ignorance in the midst of black seas of infinity, and it was not meant that we should voyage far. The sciences, each straining in its own direction, have hitherto harmed us little; but some day the piecing together of dissociated knowledge will open up such terrifying vistas of reality, and of our frightful position therein, that we shall either go mad from the revelation or flee from the deadly light into the peace and safety of a new dark age. Theosophists have guessed at the awesome grandeur of the cosmic cycle wherein our world and human race form transient incidents. They have hinted at strange survival in terms which would freeze the blood if not masked by a bland optimism. But it is not from them that there came the single glimpse of forbidden aeons which chills me when I think of it and maddens me when I dream of it. That glimpse, like all dread glimpses of truth, flashed out from an accidental piecing together of separated things—in this case an old newspaper item and the notes of a dead professor. I hope that no one else will accomplish this piecing out; certainly, if I live, I shall never knowingly supply a link in so hideous a chain. I think that the professor, too, intended to keep silent regarding the part he knew, and that he would have destroyed his notes had not sudden death seized him. My knowledge of the thing began in the winter of 1926-27 with the death of my great-uncle, George Gammell Angell, Professor Emeritus of Semitic Languages in Brown University, Providence, Rhode Island. Professor Angell was widely known as an authority on ancient inscriptions, and had frequently been resorted to by the heads of prominent museums; so that his passing at the age of ninety-two may be recalled by many. Locally, interest was intensified by the obscurity of the cause of death. The professor had been stricken whilst returning from the Newport boat; falling suddenly, as witnesses said, after having been jostled by a nautical-looking negro who had come from one of the queer dark courts on the precipitous hillside which formed a short cut from the waterfront to the deceased's home in Williams Street."
                               LineBreakMode="WordWrap" BackgroundColor="Blue"/>
                    </Grid>
                    <Grid Grid.Column="1" BackgroundColor="Green">
                        <Image Source="dogs.jpg" VerticalOptions="Center"/>
                    </Grid>
                </Grid>
                <Button Text="Take a photo" Margin="10" BackgroundColor="Gray"/>
            </StackLayout>
        </ScrollView>
    </ContentPage.Content>
lassana commented 2 years ago

Same problem with TextView placed inside of AbsoluteLayout. I ended up replacing root AbsoluteLayout with a Grid.