I have problem while i am debugging my application, when i click the button with timePicker this
Error occurs
'Binary XML file line #20: Binary XML file line #20: Error inflating class android.widget.TimePicker'
Can somebody help me with this issue
That is my XML code :
<Label Text="Godzina" Grid.Column="3" Grid.ColumnSpan="3" Grid.Row="8" TextColor="Black" Font="Bold,14"></Label>
<TimePicker x:Name="StartHour"
Format="T" Grid.Row="9" Grid.ColumnSpan="3" BindingContext="{Binding StartHour}" HorizontalOptions="FillAndExpand">
</TimePicker>
<TimePicker x:Name="EndHour"
Format="T" Grid.Row="9" Grid.ColumnSpan="3" BindingContext="{Binding EndHour}" Grid.Column="3" HorizontalOptions="FillAndExpand">
</TimePicker>
<Label Text="Miejsce spotkania" Grid.Row="10" Grid.ColumnSpan="6" TextColor="Black" Font="Bold,14"></Label>
<controls:CustomEntry x:Name="Place" Grid.ColumnSpan="6" Text="{Binding Place}" Grid.Row="11"></controls:CustomEntry>
<Label Text="Przypomnienie" Grid.Row="12" Grid.ColumnSpan="6" TextColor="Black" Font="Bold,14"></Label>
<TimePicker x:Name="Reminder"
Format="T" Grid.Row="13" BindingContext="{Binding Reminder}" Grid.ColumnSpan="6" HorizontalOptions="FillAndExpand">
</TimePicker>
<Button x:Name="MakeMeeting" Command="{Binding CreateCommand}" Text="Stworz spotkanie" Grid.ColumnSpan="6" BackgroundColor="#034ad7" BorderRadius="14" TextColor="FloralWhite" HeightRequest="50" VerticalOptions="Start" Grid.Row="14"></Button>
The reason I've found is that the TimePicker does not work with ScrollView, this is a bug, some ideas how to resolve it ?
Based on my test, we could use TimePicker work with ScorellView. I test with your layout. Due to I do not have your viewmodel, I only show the gif of layout.
Xaml:
<StackLayout>
<ScrollView>
<StackLayout>
<Label Text="Godzina" Grid.Column="3" Grid.ColumnSpan="3" Grid.Row="8" TextColor="Black" Font="Bold,14"></Label>
<TimePicker x:Name="StartHour"
Format="T" Grid.Row="9" Grid.ColumnSpan="3" BindingContext="{Binding StartHour}" HorizontalOptions="FillAndExpand">
</TimePicker>
<TimePicker x:Name="EndHour"
Format="T" Grid.Row="9" Grid.ColumnSpan="3" BindingContext="{Binding EndHour}" Grid.Column="3" HorizontalOptions="FillAndExpand">
</TimePicker>
<Label Text="Miejsce spotkania" Grid.Row="10" Grid.ColumnSpan="6" TextColor="Black" Font="Bold,14"></Label>
<!--<controls:CustomEntry x:Name="Place" Grid.ColumnSpan="6" Text="{Binding Place}" Grid.Row="11"></controls:CustomEntry>-->
<Label Text="Przypomnienie" Grid.Row="12" Grid.ColumnSpan="6" TextColor="Black" Font="Bold,14"></Label>
<TimePicker x:Name="Reminder"
Format="T" Grid.Row="13" BindingContext="{Binding Reminder}" Grid.ColumnSpan="6" HorizontalOptions="FillAndExpand">
</TimePicker>
<Button x:Name="MakeMeeting" Command="{Binding CreateCommand}" Text="Stworz spotkanie" Grid.ColumnSpan="6" BackgroundColor="#034ad7" BorderRadius="14" TextColor="FloralWhite" HeightRequest="50" VerticalOptions="Start" Grid.Row="14"></Button>
</StackLayout>
</ScrollView>
</StackLayout>
You could download from the ScorellView_TimePciker folder of GitHub for reference.
https://github.com/WendyZang/Test.git
Updated:
I test the same code in my previous reply. It could run well on Xamarin.Forms 4.4.0.991265. You could check the source code from ScorellView_TimePicker_4.4.0.991265 folder on GitHub.
https://github.com/WendyZang/Test/tree/master/ScorellView_TimePicker_4.4.0.991265/XamarinTest
Related
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:vm="clr-namespace:App1.ViewModel"
x:Class="App1.View.LoginPage" BackgroundColor="#f0f2f5">
<ContentPage.BindingContext>
<vm:LoginViewModel/>
</ContentPage.BindingContext>
<ContentPage.Content>
<StackLayout>
<Image Source="XamarinLogo.png" ></Image>
<Frame BackgroundColor="White" CornerRadius="20" WidthRequest="396" HeightRequest="430" VerticalOptions="Center" HorizontalOptions="Center" >
<StackLayout>
<Label Text="Вход на Lockdown" TextColor="Black" HorizontalOptions="Center" FontSize="Title" Margin="0,30,0,10" />
<Entry Placeholder="Логин" x:Name="login" Text="{Binding Login}" />
<Entry Placeholder="Пароль" x:Name ="password" Text="{Binding Password}" IsPassword="True"/>
<Label x:Name="LoginMessageLabel" Text="{Binding LoginMessage,Mode=OneWay}" IsVisible="{Binding TurnLoginMessage,Mode=OneWay}" Margin="10,0,0,0" TextColor="Red"></Label>
<Button x:Name="loginButton" Text="Вход" TextColor="White" BorderRadius="6" BackgroundColor="#1877F2" Margin="10,10,10,10"
Command="{Binding cmdLogin}">
</Button>
<Button x:Name="createAccount" Text="Создать новый аккаунт" TextColor="White" BorderRadius="6" BackgroundColor="#42B72A" Margin="10,10,10,10" Command="{Binding cmdCreateAccount}"/>
<Label Text="Забыли пароль?" TextColor="#1877F2" HorizontalOptions="Center">
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding cmdForgotPassword}"/>
</Label.GestureRecognizers>
</Label>
</StackLayout>
</Frame>
</StackLayout></ContentPage.Content>
what is the problem?This is my first time working with xamarin, I don't understand what the error is.What is not closed if I closed it?
you need to close every control you create. you forget to close ContentPage
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:vm="clr-namespace:App1.ViewModel"
x:Class="App1.View.LoginPage" BackgroundColor="#f0f2f5">
<ContentPage.BindingContext>
<vm:LoginViewModel/>
</ContentPage.BindingContext>
<ContentPage.Content>
<StackLayout>
<Image Source="XamarinLogo.png" ></Image>
<Frame BackgroundColor="White" CornerRadius="20" WidthRequest="396" HeightRequest="430" VerticalOptions="Center" HorizontalOptions="Center" >
<StackLayout>
<Label Text="Вход на Lockdown" TextColor="Black" HorizontalOptions="Center" FontSize="Title" Margin="0,30,0,10" />
<Entry Placeholder="Логин" x:Name="login" Text="{Binding Login}" />
<Entry Placeholder="Пароль" x:Name ="password" Text="{Binding Password}" IsPassword="True"/>
<Label x:Name="LoginMessageLabel" Text="{Binding LoginMessage,Mode=OneWay}" IsVisible="{Binding TurnLoginMessage,Mode=OneWay}" Margin="10,0,0,0" TextColor="Red"></Label>
<Button x:Name="loginButton" Text="Вход" TextColor="White" BorderRadius="6" BackgroundColor="#1877F2" Margin="10,10,10,10"
Command="{Binding cmdLogin}">
</Button>
<Button x:Name="createAccount" Text="Создать новый аккаунт" TextColor="White" BorderRadius="6" BackgroundColor="#42B72A" Margin="10,10,10,10" Command="{Binding cmdCreateAccount}"/>
<Label Text="Забыли пароль?" TextColor="#1877F2" HorizontalOptions="Center">
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding cmdForgotPassword}"/>
</Label.GestureRecognizers>
</Label>
</StackLayout>
</Frame>
</StackLayout></ContentPage.Content>
</ContentPage>
I'm using fake Api for testing app.The Api is on this link: http://jsonplaceholder.typicode.com/. I connect my App, get all photos and add to CollectionView. Everything work perfectly fine but images are not showing.Here is my code:
<Grid>
<StackLayout>
<Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0">
<Label Text="Welcome to Xamarin.Forms!" HorizontalTextAlignment="Center" TextColor="White" FontSize="36"/>
</Frame>
<RefreshView IsRefreshing="{Binding IsRefreshing, Mode=OneWay}"
Command="{Binding LoadRefreshCommand}">
<CollectionView ItemsSource="{Binding Photos}" SelectedItem="{Binding SelectedPhoto}" >
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Padding="0,0,5,0" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={x:Reference CurrentPage}, Path=BindingContext.LoadPhotosCommand}" />
</Grid.GestureRecognizers>
<Image Source="{Binding Url}" Grid.Column="0"></Image>
<Frame HasShadow="False" VerticalOptions="Center" Grid.Column="1">
<Label Text="{Binding Title}"></Label>
</Frame>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</RefreshView>
</StackLayout>
<StackLayout HorizontalOptions="CenterAndExpand" VerticalOptions="Center">
<Frame IsVisible="{Binding IsBusy}" BorderColor="#07987f" HasShadow="False" BackgroundColor="#eeeeee">
<StackLayout>
<ActivityIndicator IsVisible="{Binding IsBusy}" IsRunning="{Binding IsBusy}" HorizontalOptions="Center" VerticalOptions="Center"></ActivityIndicator>
<Label TextColor="#07987f" Text="Loading Data, Please Wait..." HorizontalTextAlignment="Center" VerticalTextAlignment="Center" HorizontalOptions="Center" VerticalOptions="Center" IsVisible="{Binding IsBusy}"/>
</StackLayout>
</Frame>
</StackLayout>
</Grid>
Here is the image i get from debug app:
What can be the problem or all images are blank.
Also i get this in the console:
[0:] HTTP Request: Could not retrieve https://via.placeholder.com/600/f66b97, status code Gone
[0:] ImageLoaderSourceHandler: Could not retrieve image or image data was invalid: Uri: https://via.placeholder.com/600/f66b97
Anyone had the same problem?
I don't know why source makes a reading problem. This is how i fix it:
Just change the following options and it should work with https too.
Android Options => Advanced
HttpClient implementation = Set to "Managed" option value
SSL/TLS implementation = set to "Native TLS 1.2+" option value
<StackLayout Grid.Row="1" Grid.Column="0" BackgroundColor="#57bcec" Padding="5" Orientation="Horizontal">
<ContentView Padding="5,0,0,0">
<ffimageloading:CachedImage DownsampleToViewSize="True" HorizontalOptions="Center" VerticalOptions="Center"
ErrorPlaceholder="{Binding PlaceholderImage}" LoadingPlaceholder="{Binding PlaceholderImage}"
Source="{Binding UserImage, Converter={Helper:ImageSourceConverter}}"
Aspect="AspectFit">
<ffimageloading:CachedImage.WidthRequest>
<OnPlatform x:TypeArguments="x:Double" iOS="40" Android="40" WinPhone="40" />
</ffimageloading:CachedImage.WidthRequest>
<ffimageloading:CachedImage.HeightRequest>
<OnPlatform x:TypeArguments="x:Double" iOS="40" Android="40" WinPhone="40" />
</ffimageloading:CachedImage.HeightRequest>
<ffimageloading:CachedImage.Transformations>
<fftransformations:CircleTransformation BorderSize="3" BorderHexColor="#34C04E"/>
</ffimageloading:CachedImage.Transformations>
</ffimageloading:CachedImage>
</ContentView>
<ContentView Padding="10,0,0,0" VerticalOptions="FillAndExpand">
<Label Text="Alan Parker" FontSize="14" FontFamily="{StaticResource Lato_Regular}" TextColor="White" VerticalOptions="Center" />
</ContentView>
</StackLayout>
Image URL: https://images.app.goo.gl/ZLSN5x9VNeebTD6z8
Output: Notice that image get cut-off from the corners
Normal Image:
I found one way to do this.
I have used: https://github.com/daniel-luberda/DLToolkit.Forms.Controls/tree/master/ImageCropView
<imgcrop:ImageCropView HeightRequest="50" WidthRequest="50" x:Name="cropView"
Source="https://anothercommonman.files.wordpress.com/2011/10/gandhiji.jpg">
<imgcrop:ImageCropView.PreviewTransformations>
<ffTransformations:CircleTransformation />
</imgcrop:ImageCropView.PreviewTransformations>
</imgcrop:ImageCropView>
I'm working with MVVM and I have a bindablelayout like this:
<StackLayout Margin="20" BindableLayout.ItemsSource="{Binding MyApartments}" >
<BindableLayout.ItemTemplate>
<DataTemplate>
<StackLayout Margin="0,10,0,0">
<Frame Padding="15" HasShadow="True" BackgroundColor="WhiteSmoke" HorizontalOptions="Fill" VerticalOptions="CenterAndExpand" HeightRequest="150" CornerRadius="15">
<StackLayout x:Name="AptItems">
<Label x:Name="apartmentlabel" Text="{Binding MyApartments.apartment}" Margin="0,15,0,0" FontFamily="{StaticResource mon_extrabold}" TextColor="DarkBlue" FontSize="Title"/>
<Label x:Name="numberlabel" Text="{Binding MyApartments.number}" FontFamily="{StaticResource mon_bold}" TextColor="DarkBlue" FontSize="Subtitle"/>
<Button HorizontalOptions="End" FontFamily="{StaticResource mon_regular}" BackgroundColor="{StaticResource bounty}" TextColor="White" Command="{Binding Path=BindingContext.SelectApartment, Source={x:Reference ApartmentsPage}}"/>
</StackLayout>
</Frame>
</StackLayout>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
I need to save the value in buildinglabel and numberlabel to my preferences but I don't know how to pass both labels to a command and searched for a long time now with no success, how is it done?
I don't know why, but when I tap any ListView item, the Button inside it's template loses the background color.
I use default ViewCell inside ListView. Is this a Xamarin.Forms bug?
I have this problem only on iOS.
<ListView x:Name="lv" Grid.Row="2" HasUnevenRows="true" BackgroundColor="White" ItemTapped="OnItemTapped">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="16" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" BackgroundColor="{Binding .,Converter={StaticResource IndexColorConverter}">
<StackLayout VerticalOptions="Center">
<Label Text="{Binding Auditorium}" FontSize="18" TextColor="Black"/>
<ContentView Padding="0,-5,0,0">
<Label Text="{Binding Title}" FontSize="16" TextColor="Black"/>
</ContentView>
<StackLayout Orientation="Horizontal">
<Button WidthRequest="100" Text="{Binding ButtonOverviewText}" TextColor="White" BackgroundColor="{Binding ButtonColor}" CommandParameter="{Binding .}" Clicked="Handle_Clicked"/>
<Button WidthRequest="100" Text="{Binding ButtonOverviewText}" TextColor="White" BackgroundColor="{Binding ButtonColor}" CommandParameter="{Binding .}" Clicked="Handle_Clicked" />
</StackLayout>
</StackLayout>
<Label Text="{Binding Coordinator}" FontSize="14" TextColor="Gray"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
There was an old issue that I filed fora similar bug: https://bugzilla.xamarin.com/show_bug.cgi?id=27502.
However, the specific scenario you mention is expected behavior on iOS and happens in native (non-Xamarin.Forms) projects too. See the comment here. You might consider disabling the UITableViewCellSelectionStyle of your cells with UITableViewCellSelectionStyle.None. Here is an example of a cell renderer. You can set the cell.SelectionStyle here. This would stop the gray highlight of the cell. If you don't want that it could be a workaround to keep your button colors.
My workaround for this problem is the following.
<Grid>
<BoxView BackgroundColor="{Binding ButtonColor}"/>
<Button Text="{Binding ButtonOverviewText}" TextColor="White" BackgroundColor="Transparent" CommandParameter="{Binding .}" Clicked="Handle_Clicked"/>
</Grid>