Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 58056 articles
Browse latest View live

How to change Android default style (colors)

$
0
0

Hi,

I have a Xamarin.Forms with only an Android Project. I was trying to change the default Android style but unfortunatelly without success.

I want to change the Listview color for select, focus and press events, which is orange.

I am using Visual Studio 2017 (15.5.4 version) and I can´t find a tutorial to do that in this version... I have found many tutorials to do that on a native Android project, which is not taking effect.

I have did that:

  • created a xml file with a selector, like that:

<?xml version="1.0" encoding="utf-8" ?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:color="#FF000000" /> <item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:color="#FF000000" /> </selector>

  • changed the style.xml file, including a new style tag like that:

``

  <style name="MainTheme" parent="MainTheme.Base">
  </style>
  <!-- Base theme applied no matter what API -->
  <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
    <item name="windowNoTitle">true</item>
    <!--We will be using the toolbar so no need to show ActionBar-->
    <item name="windowActionBar">false</item>
    <!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
    <!-- colorPrimary is used for the default action bar background -->
    <item name="colorPrimary">#2196F3</item>
    <!-- colorPrimaryDark is used for the status bar -->
    <item name="colorPrimaryDark">#1976D2</item>
    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="colorAccent">#2196F3</item>
    <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight and colorSwitchThumbNormal. -->
    <item name="windowActionModeOverlay">true</item>

    <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>

    <item name="android:listViewStyle">@style/ListViewStyle.Light</item>
  </style>

  <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorAccent">#FF4081</item>
  </style>

**  <style name="ListViewStyle.Light" parent="android:style/Widget.ListView">
    <!--<item name="background">@color/list_row_default_bg</item>-->
    <item name="android:divider">@color/divider</item>
    <item name="android:dividerHeight">2dp</item>
    <!--<item name="android:listSelector">@color/list_row_selected_bg</item>-->
    <item name="background">@drawable/item_background_selector</item>
  </style>**

</resources>
  • included attributes in the Listview control:

            <ListView ItemsSource="{Binding FaturasCollection}" 
                      RowHeight="150" 
                      HeightRequest="{Binding GridHeight}" 
                      **BackgroundColor="Transparent"**>
    
  • downloaded styles from https://www.materialpalette.com/ trying to override default style, but nothing happens.

So, my question is: Which is the correct path to do that ? I really saw so many informations, about how to do that, in so many places in the code, using or xml files, or android manifest xml file, or in .cs file, or creating xml with selectors etc but no one had the expected effect.

Please, anyone could help me ?

I need a step by step teaching how to change all Android default colors, to be able to run my app at any Android versions, with the same style, especially the ListView events colors (onselect, onpressed, onfocused).

Thanks.


Different ScrollView display behavior between iOS and Android

$
0
0

I'm seeing totally different behavior with my scroll view on iOS vs. Android. On iOS the behavior is correct, and what I see is all 20 of my items added to the scroll view. I can scroll to the end of the view and everything is looking good. Here's what that looks like:

On Android, however, it's completely wrong. I can only see about 9 elements before it looks really messed up. I can scroll a bit, but it stops prematurely at around the 9th element. Here's what the wrong display looks like:

Look at the bottom: things are overlapping each other and you don't see anything beyond the 9th element before it all gets jumbled. This behavior happens regardless of the simulator type and I've tried it with my Samsung S9 real phone. The code is the same between the two platforms. What could possibly account for the substantial difference between the two platforms with the same code?

"java.io.IOException: cannot create document. Error: 3" using Xam.Plugin.PdfRasterizer

$
0
0

I'm using the Xam.Plugin.PdfRasterizer to convert a pdf file into an image and I'm getting following error:

java.io.IOException: cannot create document. Error: 3
    at android.graphics.pdf.PdfRenderer.nativeCreate(Native Method)
    at android.graphics.pdf.PdfRenderer.<init>(PdfRenderer.java:157)

My code:

var fileData = await CrossFilePicker.Current.PickFile();
var savedFile = await FileSystem.Current.LocalStorage.CreateFileAsync(fileData.FileName, CreationCollisionOption.ReplaceExisting);
var document = await CrossPdfRasterizer.Current.RasterizeAsync(savedFile.Path, false);

What's wrong with my code?
When I'm using a public pdf path, it works. It's just when I'm picking a file from the local storage..

Thanks for your help!

Using WebView in Xamarin Forms - URL format - mailto error

$
0
0

Hi,

I'm using a webview to get a homepage rendered into my app. That works fine.
The only propblem seems mailto:... links on Android.
If I open the website in a browser from an Android device and click on the mail icon, I'm able to send a mail.
But using the webview seems to "block" this.

Getting always net::ERR_UNKNOWN_URL_SCHME

Now I've seen that I can use the ShouldOverrideUrlLoading() method to reformat this links.
But can't get it implemented.

In fact that I need it only on Android, I guess that I have to create an own webview object. But that is not working at all. Can you give a hint where to start?

thx guys.

Image Size AspectFit to fill parent StackLayout

$
0
0

Hi all - I'm having difficulty with what seems like a basic issue. I have an image that I want to fit within a stacklayout whilst keeping the aspect ratio intact. Normally, I would utilise AspectFit and all would be dandy.... however, on this project, no such luck. My guess it is possibly due to the combination of ralativelayout (to provide a background image) and grids (to display the content in the top 80%, image in the bottom 20%.

Binding ImageSource is a random group of misfit images... not all the same measurements. The result I am getting is portrait images displaying at fullsize (where I want them to be scaled down to fit). Landscape images work ok. I have tried using the HeightRequest parameter, but I am finding that on high res phones, the image is tiny.

Any ideas on how to fix, or what might be causing this behaviour?

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="NationsConnect.View.CategoryView"
             Title="{Binding PageTitle}">

    <ContentPage.Content>

        <RelativeLayout VerticalOptions="Fill" HorizontalOptions="Fill">

            <Image Source="nations_connect_logo.png" Opacity="0.1" 
                   RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width}"
                   RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height}"/>

            <Grid x:Name="serviceCategories" VerticalOptions="FillAndExpand" 
                  RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width}"
                  RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height}">

                <Grid.RowDefinitions>
                    <RowDefinition Height="80*" />
                    <RowDefinition Height="20*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <StackLayout Orientation="Vertical" HorizontalOptions="CenterAndExpand" Grid.Row="0" Grid.Column="0"  >
                    <ListView VerticalOptions="StartAndExpand" ItemsSource="{Binding Categories}" SelectedItem="{Binding SelectedCategory, Mode=TwoWay}" >

                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <ViewCell>
                                    <Grid>
                                        <StackLayout VerticalOptions="Center">
                                            <Label Text="{Binding category_name}" />
                                        </StackLayout>
                                    </Grid>
                                </ViewCell>
                            </DataTemplate>
                        </ListView.ItemTemplate>

                    </ListView>
                </StackLayout>

                <StackLayout Orientation="Vertical" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" Grid.Row="1" Grid.Column="0" >
                    <Image Source="{Binding ImageSource}" Aspect="AspectFit" />
                    <Image.GestureRecognizers>
                        <TapGestureRecognizer Command="{Binding TapImageCommand}" CommandParameter="{Binding ImageId}" />
                    </Image.GestureRecognizers>
                </StackLayout>

            </Grid>

        </RelativeLayout>
    </ContentPage.Content>
</ContentPage>

Can you have dynamic cell heights with either the ListView or TableView views?

$
0
0

Can you have dynamic cell heights with either the ListView or TableView views?

Xamarin Outside of Visual Studio

$
0
0

Just curious, is it possible to run Xamarin outside of Visual Studio? Me and Visual Studio just don't get along....and I'm afraid the time has come for one of us to go.

If the answer is no, then what other cross-platform solutions have you used and how do they compare?

reopen Application after Taking Picture from Plugin.Media sending my application into background.

$
0
0

HI
I am new in Xamarin.forms i am using xam.Plugin.Media.
While i am taking picture from the phone or choosing picture from gallery , My Application going into background.
how to overcome with this problem.


visual studio bug

$
0
0

hello, i'm new to coding and don't have any experience but i just installed visual studio installed the sdk/ndk and created a device. I clicked file/new/c#/android/blank app and when I created the project and open main.axml I have an error on the bottom. I reinstalled windows and looked up my issue but couldn't find this anywhere. here are some screenshots (keep in mind like i said this is a brand new project i didn't even type one line of code in and i also reset windows)

since I just made this account I'm not allowed to post links so you're gonna have to stitch this for screenshots, sorry!

imgur . com/a/83faq

"This project contains resources that were not compiled successfully rendering might be affected"

get current location Xam.Plugin.Geolocator

$
0
0

i use Xam.Plugin.Geolocator, i did the same as the documentation, and it work find in android emulator, but when i deploy it to my mobile,
i got this exception:

{System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Plugin.Geolocator.FusedGeolocatorImplementation+d__32.MoveNext () [0x00450] in C:\projects\geolocatorplugin\src\Geolocator.Plugin.Android\FusedGeolocatorImplementation.cs:221
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0001a] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at RealShopOnline.Views.SecondPageVolumes+d__5.MoveNext () [0x00077] in E:\MyLovelyApps\RealMobileApp\RealShopOnline\RealShopOnline\RealShopOnline\Views\SecondPageVolumes.cs:166 }

any help?

Blurred ContentView

$
0
0

I need a content view that blurs whatever is below it so I thought I'd try writing a custom control and an iOS renderer for it. This is the class definition ...

public class XBlurredContentView : ContentView
{
}

... here's the custom renderer ...

public class XBlurFrameRenderer : ViewRenderer<XBlurredContentView,UIView>
{
    private UIVisualEffectView _effectView;

    protected override void OnElementChanged(ElementChangedEventArgs<XBlurredContentView> e)
    {
        base.OnElementChanged(e);
        var blurFrame = e.NewElement;
        if (blurFrame != null)
        {
            var effect = UIBlurEffect.FromStyle(UIBlurEffectStyle.Light);
            _effectView = new UIVisualEffectView(effect);
            SetNativeControl(_effectView);
        }
    }

    protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        if (e.PropertyName == VisualElement.XProperty.PropertyName
            || e.PropertyName == VisualElement.YProperty.PropertyName
            || e.PropertyName == VisualElement.HeightProperty.PropertyName
            || e.PropertyName == VisualElement.WidthProperty.PropertyName)
        {
            var x = Element.X; var y = Element.Y; var w = Element.Width; var h = Element.Height;
            _effectView.Frame = new CGRect(x, y, w, h);
        }
        base.OnElementPropertyChanged(sender, e);
    }
}

... and here's the XAML to test it ...

    <customUi:XBlurredContentView HeightRequest="50">
        <Grid>
            <Button Text="Hello World" TextColor="White" />
        </Grid>
    </customUi:XBlurredContentView>

The expected are does get blurred as expected but the content (the "Hello World" button isn't visible. I double checked with the Live Inspector and it does look like the button (and it's UILabel) is added correctly but nothing is visible on screen. This is my first go at deriving the ContentView into a custom control so I guess I need to learn more but what have I missed?

Testing Modified xamarin cross plat library/plugin using DLL referencing

$
0
0

If I fork one of the open source xamarin forms plugin (ex. JamesMontemagno's connectivity plugin)

And If I make some modification to it,

How can I test the modified plugin on PCL project using reference to DLL not nuget?

How to wrap the text in EditText Control in Xamarin.Forms?

$
0
0

Hi All,

I have tried to wrap the text in EditText class in Xamarin.Forms. But it is not working in XForms.Android and Xamarin.Android(Native).

I have tried with Gravity property of EditText class and googled lot. But i didnot get any idea on this.

Textwrapping is working fine in XForms.UWP and XForms.IOS.

Is there any way to achieve this?

Regards,
Srinivasan

How do I resolve MT0117 Error? (Can't launch a 32-bit app)

$
0
0

I'm going through the blog on CarouselView for Xamarin.Forms. I'm running into this error:
Launch failed. The app 'Monkeys.iOS' could not be launched on 'iPhone 8 Plus iOS 11.2'. Error: error MT0117: Can't launch a 32-bit app on a simulator that only supports 64-bit apps (iPhone 8 Plus).

How do I get past this so I can launch the app on iOS Simulator?

Use EntryCell for password and change visibility?

$
0
0

Hello,

I have a settings page in my app where I want to display several entry fields, toggle switches and change the visibility of some entry fields depending on the state of the toggle switch.

I had so far managed this without table views and cells using a simple grid layout and placing my items (entry, label and switch) in there. I was able to solve the visibility by setting it to a binding.

However, I recently learned about cells and I would like to use the entrycell and switchcell for its simple and implementation and the ability to show text next to a switch.

Is there any way to derive a class from Entrycell and only change the IsPassword property of the entry?

Is there any way to change the visibility of a cell item? I thought about wrapping it inside something that has a IsVisible Property (e.g. Grid or StackLayout) but cannot figure out how to add these to a cell.


Set navigation bar title position to center in xamarin forms is it possible? If possible how to do??

$
0
0
How to set navigation bar title position to center in xamarin forms?

ZXing.Net.Mobile bar code scanner problem

$
0
0

I had implement the bar code scanner and it work fine for the first time, based on what I know is you need to have ZXing scanner page to activate the camera to scan.

However when you scan the bar code second time it will show you the previous scanner page and you need to press back to show back the page which display the result. It doesn't remove that page from the navigation stack even I apply POPASYNC.

Anyone can help?

GET webdata - Working on UWP, Android not building connection

$
0
0

I've been requesting some DATA using the a nuget plugin (Binance.NET) in my shared Project. Works flawlessly on UWP aswell as a .net core and asp.net application i am running but for some reason on android debugging it can not get the data.

It throws following error when using it in the constructor or calling the data later on through a button.
"Web error: No response from server"

Is there a obvious Android behaviour that i am not familiar with and am ignoring?

Xamarin form build apk how to reduce file size?

$
0
0

I have a problem when exporting apk file with xamarin form project, file size is too large. Without a linker with a blank application, its capacity is 65 Mb. After I used the linker: Sdk and User Assemblies the capacity has dropped to 11 Mb (it is still huge for a blank application). I have read through some articles about skip unused libraries such as Mono.android and mscorlib, when I inserted the configuration "Skip linking Assemblies -> Mono.Android.dll; mscorlib.dll" File size remains unchanged. Can the file size be reduced again? Or is it a minimum or average file size when exporting to apk? Anyone can help me?
Sorry for my bad english.
Thank you in advance.

Add Tabbed Page Inside Content page.

$
0
0

I want to tabbed item Inside Content Page Because i have to Display Some Button Inside Content page with tabbedPage. Anyone suggest me how can i do .i have attached image what exactly i want.please reply as soon as possible. thanx in advance. is it possible to design i have attached ???

Viewing all 58056 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>