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 -->
Related
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.
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"
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>
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
I am new in monodevelop/monoandroid.I need code for showing multiline text in textview I have tried bellow but still its not working.I think there should be some code that I have to include in .cs file,but I am not getting what to use there.
I have used c# code also but its not working. I think ellipsize is a android attribute thats why its not working.Please give me some solution.
<ScrollView
android:id="#+id/scrollView2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="10dip"
android:orientation="vertical"
android:layout_gravity="center" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_marginTop="10dip">
<TextView
android:id="#+id/tv_policy1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:text="Terms of Service O-job Information Terms of Service O-job Information Terms of Service O-job Information Terms of Service O-job Information for Personal non-commercialaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaa aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaa use only sdfjkj asdfjklfj sdfjkljdf sdfjkljflkj sdfskjfkl sdfjklsdjf sdfkljsdklfj sdfjhsdkfh"
android:textColor="#000000"
android:maxLines="3"
android:singleLine="false"
android:textSize="14dip" />
</RelativeLayout>
</ScrollView>
Please advice....
Thanks in advance!
Try this format:
<ScrollView>
<RelativeLayout>
<TextView/>
<TextView/>
<RelativeLayout/>
<ScrollView/>
Then you can use the align methods given in a RelativeLayout.
Edit:
Explain what your problem is! Do you get an error when compiling or is the text not shown properly? Be more specific.
Also, why do you use attributes like : android:maxLines="3" or android:singleLine="false" or android:layout_height="60dip" in your TextView. Translated this means: The text must have more than one line but a maximum of 3. Also it can't be longer than 60dip.
Depending on the Text that are very strict rules. Use these rules android:layout_width="match_parent" android:layout_height="wrap_content" to make sure that the text can be displayed correctly, remove the attributes I mentioned before in your TextView.