Xamarin.Forms. How to make animation Slide show & Fade for search?
I have a component:
<Grid VerticalOptions="CenterAndExpand" HorizontalOptions="FillAndExpand" x:Name="grid">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Entry Grid.Row="0" x:Name="textField" Keyboard="Text" BackgroundColor="#a6ffffff" />
<Image Source="Search.png" HorizontalOptions="StartAndExpand" WidthRequest="25" HeightRequest="25">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="Image_Tapped" />
</Image.GestureRecognizers>
</Image>
</Grid>
This component is located in AbsoluteLayout in the right corner. When I click on the picture, my object goes from right to left. But it works jerky. Here is my animation:
void Image_Tapped(object sender, EventArgs e)
{
var img = sender as Image;
var animation = new Animation();
var textFieldTranslate = new Animation(v => textField.TranslationX = v, img.Width img.Width - 300);
var textFieldChangeWidth = new Animation(v => textField.WidthRequest = v, 0, 300);
animation.Add(0, 1, textFieldTranslate);
animation.Add(0, 1, textFieldChangeWidth);
animation.Commit(this, "Slide", 1000, 500, Easing.Linear);
}
How can I fix this? How to achieve smoothness?
Below is an example of animation. Panel leaves from right to left.
Maybe there are other solutions to this problem?
And also after the animation has completed, Entry does not respond to tap. What can it be connected with and how to fix it?
<Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" ColumnSpacing="0" RowSpacing="0"
Padding="{StaticResource ContentPagePadding}" BackgroundColor="#000017">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="9*" />
</Grid.RowDefinitions>
<ContentPresenter VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Grid.Row="1" Padding="5, 0" />
<AbsoluteLayout>
<Image Source="logo.png" AbsoluteLayout.LayoutBounds=".1, 0, .3, 1" AbsoluteLayout.LayoutFlags="All" />
<Image Source="bookmark.png" AbsoluteLayout.LayoutBounds=".8, .5, .1, .4" AbsoluteLayout.LayoutFlags="All" >
<Image.GestureRecognizers>
<TapGestureRecognizer Command="{TemplateBinding BookmarkCommand}" />
</Image.GestureRecognizers>
</Image>
<AbsoluteLayout AbsoluteLayout.LayoutBounds=".9, .4, .1, .4" AbsoluteLayout.LayoutFlags="All">
<ctrl:SearchView />
</AbsoluteLayout>
</AbsoluteLayout>
</Grid>
animation xamarin.forms slideshow
add a comment |
I have a component:
<Grid VerticalOptions="CenterAndExpand" HorizontalOptions="FillAndExpand" x:Name="grid">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Entry Grid.Row="0" x:Name="textField" Keyboard="Text" BackgroundColor="#a6ffffff" />
<Image Source="Search.png" HorizontalOptions="StartAndExpand" WidthRequest="25" HeightRequest="25">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="Image_Tapped" />
</Image.GestureRecognizers>
</Image>
</Grid>
This component is located in AbsoluteLayout in the right corner. When I click on the picture, my object goes from right to left. But it works jerky. Here is my animation:
void Image_Tapped(object sender, EventArgs e)
{
var img = sender as Image;
var animation = new Animation();
var textFieldTranslate = new Animation(v => textField.TranslationX = v, img.Width img.Width - 300);
var textFieldChangeWidth = new Animation(v => textField.WidthRequest = v, 0, 300);
animation.Add(0, 1, textFieldTranslate);
animation.Add(0, 1, textFieldChangeWidth);
animation.Commit(this, "Slide", 1000, 500, Easing.Linear);
}
How can I fix this? How to achieve smoothness?
Below is an example of animation. Panel leaves from right to left.
Maybe there are other solutions to this problem?
And also after the animation has completed, Entry does not respond to tap. What can it be connected with and how to fix it?
<Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" ColumnSpacing="0" RowSpacing="0"
Padding="{StaticResource ContentPagePadding}" BackgroundColor="#000017">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="9*" />
</Grid.RowDefinitions>
<ContentPresenter VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Grid.Row="1" Padding="5, 0" />
<AbsoluteLayout>
<Image Source="logo.png" AbsoluteLayout.LayoutBounds=".1, 0, .3, 1" AbsoluteLayout.LayoutFlags="All" />
<Image Source="bookmark.png" AbsoluteLayout.LayoutBounds=".8, .5, .1, .4" AbsoluteLayout.LayoutFlags="All" >
<Image.GestureRecognizers>
<TapGestureRecognizer Command="{TemplateBinding BookmarkCommand}" />
</Image.GestureRecognizers>
</Image>
<AbsoluteLayout AbsoluteLayout.LayoutBounds=".9, .4, .1, .4" AbsoluteLayout.LayoutFlags="All">
<ctrl:SearchView />
</AbsoluteLayout>
</AbsoluteLayout>
</Grid>
animation xamarin.forms slideshow
Sorry, but I can't see what's the issue with the animation. Or is the GIF not your actual animation, but an example how it should look?
– Paul Kertscher
Nov 21 '18 at 13:22
@PaulKertscher GIF - example how it should look
– Viktor
Nov 21 '18 at 13:45
add a comment |
I have a component:
<Grid VerticalOptions="CenterAndExpand" HorizontalOptions="FillAndExpand" x:Name="grid">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Entry Grid.Row="0" x:Name="textField" Keyboard="Text" BackgroundColor="#a6ffffff" />
<Image Source="Search.png" HorizontalOptions="StartAndExpand" WidthRequest="25" HeightRequest="25">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="Image_Tapped" />
</Image.GestureRecognizers>
</Image>
</Grid>
This component is located in AbsoluteLayout in the right corner. When I click on the picture, my object goes from right to left. But it works jerky. Here is my animation:
void Image_Tapped(object sender, EventArgs e)
{
var img = sender as Image;
var animation = new Animation();
var textFieldTranslate = new Animation(v => textField.TranslationX = v, img.Width img.Width - 300);
var textFieldChangeWidth = new Animation(v => textField.WidthRequest = v, 0, 300);
animation.Add(0, 1, textFieldTranslate);
animation.Add(0, 1, textFieldChangeWidth);
animation.Commit(this, "Slide", 1000, 500, Easing.Linear);
}
How can I fix this? How to achieve smoothness?
Below is an example of animation. Panel leaves from right to left.
Maybe there are other solutions to this problem?
And also after the animation has completed, Entry does not respond to tap. What can it be connected with and how to fix it?
<Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" ColumnSpacing="0" RowSpacing="0"
Padding="{StaticResource ContentPagePadding}" BackgroundColor="#000017">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="9*" />
</Grid.RowDefinitions>
<ContentPresenter VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Grid.Row="1" Padding="5, 0" />
<AbsoluteLayout>
<Image Source="logo.png" AbsoluteLayout.LayoutBounds=".1, 0, .3, 1" AbsoluteLayout.LayoutFlags="All" />
<Image Source="bookmark.png" AbsoluteLayout.LayoutBounds=".8, .5, .1, .4" AbsoluteLayout.LayoutFlags="All" >
<Image.GestureRecognizers>
<TapGestureRecognizer Command="{TemplateBinding BookmarkCommand}" />
</Image.GestureRecognizers>
</Image>
<AbsoluteLayout AbsoluteLayout.LayoutBounds=".9, .4, .1, .4" AbsoluteLayout.LayoutFlags="All">
<ctrl:SearchView />
</AbsoluteLayout>
</AbsoluteLayout>
</Grid>
animation xamarin.forms slideshow
I have a component:
<Grid VerticalOptions="CenterAndExpand" HorizontalOptions="FillAndExpand" x:Name="grid">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Entry Grid.Row="0" x:Name="textField" Keyboard="Text" BackgroundColor="#a6ffffff" />
<Image Source="Search.png" HorizontalOptions="StartAndExpand" WidthRequest="25" HeightRequest="25">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="Image_Tapped" />
</Image.GestureRecognizers>
</Image>
</Grid>
This component is located in AbsoluteLayout in the right corner. When I click on the picture, my object goes from right to left. But it works jerky. Here is my animation:
void Image_Tapped(object sender, EventArgs e)
{
var img = sender as Image;
var animation = new Animation();
var textFieldTranslate = new Animation(v => textField.TranslationX = v, img.Width img.Width - 300);
var textFieldChangeWidth = new Animation(v => textField.WidthRequest = v, 0, 300);
animation.Add(0, 1, textFieldTranslate);
animation.Add(0, 1, textFieldChangeWidth);
animation.Commit(this, "Slide", 1000, 500, Easing.Linear);
}
How can I fix this? How to achieve smoothness?
Below is an example of animation. Panel leaves from right to left.
Maybe there are other solutions to this problem?
And also after the animation has completed, Entry does not respond to tap. What can it be connected with and how to fix it?
<Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" ColumnSpacing="0" RowSpacing="0"
Padding="{StaticResource ContentPagePadding}" BackgroundColor="#000017">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="9*" />
</Grid.RowDefinitions>
<ContentPresenter VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Grid.Row="1" Padding="5, 0" />
<AbsoluteLayout>
<Image Source="logo.png" AbsoluteLayout.LayoutBounds=".1, 0, .3, 1" AbsoluteLayout.LayoutFlags="All" />
<Image Source="bookmark.png" AbsoluteLayout.LayoutBounds=".8, .5, .1, .4" AbsoluteLayout.LayoutFlags="All" >
<Image.GestureRecognizers>
<TapGestureRecognizer Command="{TemplateBinding BookmarkCommand}" />
</Image.GestureRecognizers>
</Image>
<AbsoluteLayout AbsoluteLayout.LayoutBounds=".9, .4, .1, .4" AbsoluteLayout.LayoutFlags="All">
<ctrl:SearchView />
</AbsoluteLayout>
</AbsoluteLayout>
</Grid>
animation xamarin.forms slideshow
animation xamarin.forms slideshow
asked Nov 21 '18 at 13:04
Viktor
224
224
Sorry, but I can't see what's the issue with the animation. Or is the GIF not your actual animation, but an example how it should look?
– Paul Kertscher
Nov 21 '18 at 13:22
@PaulKertscher GIF - example how it should look
– Viktor
Nov 21 '18 at 13:45
add a comment |
Sorry, but I can't see what's the issue with the animation. Or is the GIF not your actual animation, but an example how it should look?
– Paul Kertscher
Nov 21 '18 at 13:22
@PaulKertscher GIF - example how it should look
– Viktor
Nov 21 '18 at 13:45
Sorry, but I can't see what's the issue with the animation. Or is the GIF not your actual animation, but an example how it should look?
– Paul Kertscher
Nov 21 '18 at 13:22
Sorry, but I can't see what's the issue with the animation. Or is the GIF not your actual animation, but an example how it should look?
– Paul Kertscher
Nov 21 '18 at 13:22
@PaulKertscher GIF - example how it should look
– Viktor
Nov 21 '18 at 13:45
@PaulKertscher GIF - example how it should look
– Viktor
Nov 21 '18 at 13:45
add a comment |
1 Answer
1
active
oldest
votes
I created component HeaderView:
<AbsoluteLayout>
<FlexLayout Direction="RowReverse" AbsoluteLayout.LayoutBounds=".1, .5, .9, .5"
AbsoluteLayout.LayoutFlags="All">
<ctrl:ExtendedEntry x:Name="textField"
Style="{StaticResource SearchEntryStyle}"
Placeholder="{ext:Translate Search_placeholder}"
TextChanged="Handle_TextChanged" />
</FlexLayout>
<Image Source="Search.png" x:Name="image"
AbsoluteLayout.LayoutBounds=".9, .5, .1, .4" AbsoluteLayout.LayoutFlags="All">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="Image_Tapped" />
</Image.GestureRecognizers>
</Image>
</AbsoluteLayout>
C# code:
void AnimationIn()
{
textField.IsVisible = true;
image.Source = "Search_active.png";
new Animation(v => textField.WidthRequest = v, 0, EntryWidth)
.Commit(this, "SlideIn", 1000, ANIMATION_TIME, Easing.CubicIn);
}
void AnimationOut()
{
new Animation(v => textField.WidthRequest = v, EntryWidth, 0)
.Commit(this, "SlideOut", 1000, ANIMATION_TIME, Easing.CubicOut);
image.Source = "Search.png";
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412694%2fxamarin-forms-how-to-make-animation-slide-show-fade-for-search%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I created component HeaderView:
<AbsoluteLayout>
<FlexLayout Direction="RowReverse" AbsoluteLayout.LayoutBounds=".1, .5, .9, .5"
AbsoluteLayout.LayoutFlags="All">
<ctrl:ExtendedEntry x:Name="textField"
Style="{StaticResource SearchEntryStyle}"
Placeholder="{ext:Translate Search_placeholder}"
TextChanged="Handle_TextChanged" />
</FlexLayout>
<Image Source="Search.png" x:Name="image"
AbsoluteLayout.LayoutBounds=".9, .5, .1, .4" AbsoluteLayout.LayoutFlags="All">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="Image_Tapped" />
</Image.GestureRecognizers>
</Image>
</AbsoluteLayout>
C# code:
void AnimationIn()
{
textField.IsVisible = true;
image.Source = "Search_active.png";
new Animation(v => textField.WidthRequest = v, 0, EntryWidth)
.Commit(this, "SlideIn", 1000, ANIMATION_TIME, Easing.CubicIn);
}
void AnimationOut()
{
new Animation(v => textField.WidthRequest = v, EntryWidth, 0)
.Commit(this, "SlideOut", 1000, ANIMATION_TIME, Easing.CubicOut);
image.Source = "Search.png";
}
add a comment |
I created component HeaderView:
<AbsoluteLayout>
<FlexLayout Direction="RowReverse" AbsoluteLayout.LayoutBounds=".1, .5, .9, .5"
AbsoluteLayout.LayoutFlags="All">
<ctrl:ExtendedEntry x:Name="textField"
Style="{StaticResource SearchEntryStyle}"
Placeholder="{ext:Translate Search_placeholder}"
TextChanged="Handle_TextChanged" />
</FlexLayout>
<Image Source="Search.png" x:Name="image"
AbsoluteLayout.LayoutBounds=".9, .5, .1, .4" AbsoluteLayout.LayoutFlags="All">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="Image_Tapped" />
</Image.GestureRecognizers>
</Image>
</AbsoluteLayout>
C# code:
void AnimationIn()
{
textField.IsVisible = true;
image.Source = "Search_active.png";
new Animation(v => textField.WidthRequest = v, 0, EntryWidth)
.Commit(this, "SlideIn", 1000, ANIMATION_TIME, Easing.CubicIn);
}
void AnimationOut()
{
new Animation(v => textField.WidthRequest = v, EntryWidth, 0)
.Commit(this, "SlideOut", 1000, ANIMATION_TIME, Easing.CubicOut);
image.Source = "Search.png";
}
add a comment |
I created component HeaderView:
<AbsoluteLayout>
<FlexLayout Direction="RowReverse" AbsoluteLayout.LayoutBounds=".1, .5, .9, .5"
AbsoluteLayout.LayoutFlags="All">
<ctrl:ExtendedEntry x:Name="textField"
Style="{StaticResource SearchEntryStyle}"
Placeholder="{ext:Translate Search_placeholder}"
TextChanged="Handle_TextChanged" />
</FlexLayout>
<Image Source="Search.png" x:Name="image"
AbsoluteLayout.LayoutBounds=".9, .5, .1, .4" AbsoluteLayout.LayoutFlags="All">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="Image_Tapped" />
</Image.GestureRecognizers>
</Image>
</AbsoluteLayout>
C# code:
void AnimationIn()
{
textField.IsVisible = true;
image.Source = "Search_active.png";
new Animation(v => textField.WidthRequest = v, 0, EntryWidth)
.Commit(this, "SlideIn", 1000, ANIMATION_TIME, Easing.CubicIn);
}
void AnimationOut()
{
new Animation(v => textField.WidthRequest = v, EntryWidth, 0)
.Commit(this, "SlideOut", 1000, ANIMATION_TIME, Easing.CubicOut);
image.Source = "Search.png";
}
I created component HeaderView:
<AbsoluteLayout>
<FlexLayout Direction="RowReverse" AbsoluteLayout.LayoutBounds=".1, .5, .9, .5"
AbsoluteLayout.LayoutFlags="All">
<ctrl:ExtendedEntry x:Name="textField"
Style="{StaticResource SearchEntryStyle}"
Placeholder="{ext:Translate Search_placeholder}"
TextChanged="Handle_TextChanged" />
</FlexLayout>
<Image Source="Search.png" x:Name="image"
AbsoluteLayout.LayoutBounds=".9, .5, .1, .4" AbsoluteLayout.LayoutFlags="All">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="Image_Tapped" />
</Image.GestureRecognizers>
</Image>
</AbsoluteLayout>
C# code:
void AnimationIn()
{
textField.IsVisible = true;
image.Source = "Search_active.png";
new Animation(v => textField.WidthRequest = v, 0, EntryWidth)
.Commit(this, "SlideIn", 1000, ANIMATION_TIME, Easing.CubicIn);
}
void AnimationOut()
{
new Animation(v => textField.WidthRequest = v, EntryWidth, 0)
.Commit(this, "SlideOut", 1000, ANIMATION_TIME, Easing.CubicOut);
image.Source = "Search.png";
}
answered Nov 30 '18 at 11:57
Viktor
224
224
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412694%2fxamarin-forms-how-to-make-animation-slide-show-fade-for-search%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Sorry, but I can't see what's the issue with the animation. Or is the GIF not your actual animation, but an example how it should look?
– Paul Kertscher
Nov 21 '18 at 13:22
@PaulKertscher GIF - example how it should look
– Viktor
Nov 21 '18 at 13:45