VS Mac cannot drag/drop from toolbox onto Android layout - xamarin.android

Versions:
MacOS: Ventura 13.0.1
VS Mac: 17.4.1 (build 28)
Android extensions: 17.4.x
My layout xml looks like this:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:showIn="#layout/activity_main"
android:minWidth="25px"
android:minHeight="25px"
android:id="#+id/main_layout">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/main_prompt"
android:id="#+id/main_prompt" />
</LinearLayout>
When I drag anything (say Button) from the toolbox into the layout xml or onto the design view, it just disappears (it actually flies back to the toolbox). No other indicators whatsoever. I want to add controls after the above TextView control.
I was expecting the new control to show up in the layout xml and the design view. I cannot understand why there is no visual feedback. It just does not work.

Related

Xamarin Android -TextInputLayout how should I wrap hint to next line of TextInputEditText?

Xamarin Android -TextInputLayout how should I wrap hint to next line of TextInputEditText ?
You could use LinearLayout to display a linear direction of elements.
Xaml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TextInputEditText
android:id="#+id/textInputEditText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextInputEditText"/>
<android.support.design.widget.TextInputLayout
android:id="#+id/textInputLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/material_blue_grey_800">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
Screenshot:
Updated:
If you want to hint text which is cutting off, you could make a scroll.
android:scrollHorizontally="true"
android:singleLine="true"

Add button on Sliding Tab Layout fragment android xamarin

I want to add a RecyclerView and button inside FragmentLayout1 in slide tab bag.
I made the following attempt, but the RecyclerView and button appeared with all tabs and not a specific tab. In addition to stopping the application when adding a pressure event to the button.
FragmentLayout1.axml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:scrollbars="vertical"
android:layout_width="fill_parent"
android:layout_height="341.0dp" />
<FrameLayout
android:id="#+id/buttonPanel"
android:layout_width="162.5dp"
android:layout_height="50dp"
android:layout_gravity="top|end"
android:layout_marginEnd="0dp"
android:layout_marginRight="0dp">
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px"
android:id="#+id/button1" />
</FrameLayout>

Clicking btn calling snackbar causes crash

Firstly, this is my first time trying Xamarin (SDK Tools 26.1.1, SDK Platform Tools 28.0, SDK Build Tools 27.0.0)
Without any amendments to the sample code, the FloatingActionButton successfully displays the Snackbar.
But after experimenting, I discovered if I add an ID to the sample TextView, the Snackbar triggered by the FAB causes a crash.
Why is that so? How can I overcome this? i.e including ID without crash
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:id="#+id/textView1"
android:text="Hello World!" />
Thanx & Rgds,
ref
Dialog on VS:
Unhandled Exception:
Android.Views.InflateException: occurred
Dialog on device:
[appname] has stopped
open app again
[add entire file as requested]
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:showIn="#layout/activity_main">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:id="#+id/textView1"
android:text="Hello World!" />
</RelativeLayout>

#region in axml file for xamarin.android

hello I am trying to make my code in the axml file more readable I have a lot of switches in my program and I want to shrink this part of the code. I read something about it and I found
<!--#region Name-->
My Code
<!--#endregion-->
But it is referred as a normal comment. Could you help me out? I am using Visual Studio 2017 in case it is important to mention.
# region in axml file for xamarin.android
If you want to make the .axml file more readable, you could click the indent button: Effect.
Or you could use the <include/> tag embed another layout inside the current layout to make it more readable. For example, create a titlebar.axml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/titlebar_bg"
tools:showIn="#layout/activity_main" >
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/gafricalogo" />
</FrameLayout>
Use it in another layout file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/app_bg"
android:gravity="center_horizontal">
<include layout="#layout/titlebar"/>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/hello"
android:padding="10dp" />
...
</LinearLayout>
Update:
I think the XAML Regions is what you are looking in your .axml file.
Update 2:
Install this plugin for your Visual Studio, close all your Visual Studio windows and reopen the VS. Then, you could the the #Region function for your
<!-- Region (Any Text You Want) -->
Your Code
<!-- EndRegion -->

MVVMCross w/ Bugsense causes weird issues with binding EditText on Android

I ran into a very weird situation when I installed the BugSense package on my MVVMCross app. Every time I type a letter into the EditText the cursor moves to the first character. This is highly annoying as I have to arrow over to the end of the field to type the next character!
What I did was on the override of the "OnCreate" of my SplashScreenView I set up this:
protected override void OnCreate(Bundle bundle)
{
BugSenseHandler.Instance.InitAndStartSession(new ExceptionManager(), ApplicationContext, "xxxxxxxx");
base.OnCreate(bundle);
}
When my splash screen goes away it moves to my LoginViewModel. My axml for my Login View looks like so:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/white_full_box">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerHorizontal="false"
android:layout_centerInParent="true"
android:layout_marginBottom="#dimen/table_margin"
android:layout_marginLeft="#dimen/table_margin"
android:layout_marginTop="#dimen/dialog_margin"
android:padding="#dimen/zero"
android:background="#drawable/white_full_box">
<EditText
android:id="#+id/username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/password"
android:layout_centerHorizontal="true"
android:layout_marginBottom="40dp"
android:ems="10"
android:hint="username"
android:layout_marginLeft="#dimen/table_margin"
android:inputType="textVisiblePassword"
android:singleLine="true"
local:MvxBind="Text UserName">
<requestFocus />
</EditText>
<EditText
android:id="#+id/password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:ems="10"
android:hint="password"
android:layout_marginLeft="#dimen/table_margin"
android:inputType="textPassword"
local:MvxBind="Text Password" />
<Button
android:id="#+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/password"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:layout_marginRight="#dimen/dialog_margin"
android:text="Login"
style="#style/ButtonStyle"
local:MvxBind="Click LoginCommand" />
</RelativeLayout>
</RelativeLayout>
And I just have normal properties that bind to the Username, Password and Login button in the view model. I did a couple things to verify this behavior:
1.) I left the bugsense initialization code and removed the Text bind from the username. In this scenario the username would behave properly but the password field would always move the character to the first character after each text entry.
2.) I reimplemented the text bind to the username field and then commented out the BugSense initialization code and everything appeared to work correctly again.
What is happening here? Where should I be doing the BugSense initialization in an MVVMCross app?
My solution was to switch to Raygun.io because that does not appear to have the same issue.
Bugsense does appear to be looking into the issue which you can follow along HERE

Resources