0

I'm currently developing an Android app using Xamarin.Android. In this app, I have a SearchView that I made smaller than the standard size. So, when I type in it, the text is too big to be fully shown inside the bar. I searched for this and found this link :

How to remove inner bottom space (bottom margin/padding) of text/layout inside a SearchView?

The person that made this post is looking for the exact same result than me, except he's not using Xamarin. I found similar posts, all for Android, with the same answer that seems to work.

I'm looking for the Xamarin equivalent to that answer :

AutoCompleteTextView searchTextContent = (AutoCompleteTextView) searchBar.findViewById(searchBar.getContext().getResources().getIdentifier("android:id/search_src_text", null, null));

As getContext(), getResources(), etc aren't existing in Xamarin, but probably have an equivalent way to get this AutoCompleteTextView.

Thanks in advance !

Community
  • 1
  • 1
YumeYume
  • 981
  • 2
  • 12
  • 33

1 Answers1

1

Here: This should help you

you can use

Application.Context 

or more specifically,

Android.App.Application.Context

instead of getContext()

for your getResources() make it GetResources()

So this is the solution:

AutoCompleteTextView searchQuery = searchBar.FindViewById<AutoCompleteTextView>(Application.Context.Resources.GetId‌​entifier("android:id/search_src_text", null, null)); 
searchQuery.TextSize = 15;
searchQuery.Gravity = GravityFlags.Bottom;

Happy Coding

Akshay Kulkarni
  • 729
  • 6
  • 22
  • 1
    Thanks a lot ! Your post sent me the right way, and I had the desired result with these : AutoCompleteTextView searchQuery = searchBar.FindViewById(Application.Context.Resources.GetIdentifier("android:id/search_src_text", null, null)); searchQuery.TextSize = 15; searchQuery.Gravity = GravityFlags.Bottom; I mark your post as the answer, you can add those lines directly into it as I have trouble formatting my answer in comments. Thanks again ! – YumeYume Apr 13 '16 at 08:16