Android studio 2.2 EditText Border - android-edittext

I upgraded Android Studio 2.2 preview 3 recently but the EditText style changed, In preView:
But run on my phone, It like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.hyh.newlearn.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
<EditText
android:id="#+id/et_show"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:hint="Hello World"/>
</RelativeLayout>
styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
</resources>
Why? How to deal with it?

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-alpha3'
// classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
If I use classpath 'com.android.tools.build:gradle:2.2.0-alpha3', it will show the error view.
If I use classpath 'classpath 'com.android.tools.build:gradle:1.5.0'', it will show the right view.

I have exaclty the same problem.
Yuhao, here is my question
android edittext on sdk version from 16-19 shown incorrectly.
but i thought it was couse of api.
You were right.
We have to use last stable version
'com.android.tools.build:gradle:2.1.0'

Related

Xamairin forms : Android.Views.InflateException: <Timeout exceeded getting exception details>

Research a lot about this issue and found the same question, which doesn't solve my problem. so starting a new question.
Xamarin Android: Android.Views.InflateException - Error when loading Layout
Getting Xamairin forms : Android.Views.InflateException: Timeout exceeded getting exception details when loading layout.
Main.axml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFCDD2"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_name"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/input_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:hint="#string/hint_name" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_email"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/input_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:hint="#string/hint_email" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_password"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/input_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:hint="#string/hint_password" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/btn_signup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/btn_sign_up"
android:background="#color/colorPrimary"
android:layout_marginTop="40dp"
android:textColor="#android:color/white" />
</LinearLayout>
I have not used layout:width and layout:height properties in my axml and only using an icon having 4kb size.
Please suggest a solution for this issue, thanks in advance...
Getting Xamairin forms : Android.Views.InflateException: Timeout exceeded getting exception details when loading layout.
There are two things needs to be confirmed before using TextInputLayout:
Please make sure, Xamarin.Android.Support.Design lib is correctly referenced in your Xamarin.Android project. If you are using Xamarin.Forms, it should be referenced by default.
Please make sure the Activity is of type Android.Support.V7.App.AppCompatActivity.
If none of the above things help, please provide a basic demo that can reproduce the problem.
Update:
Upon testing on the project you shared. I found you need to use a Theme.AppCompat theme for your activity, you can do that by following below steps:
Create a styles.xml file under Resources\values\ folder with below codes:
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
</style>
</resources>
In MainActivity.cs define the Activity attribute to leverage AppTheme like this:
[Activity(Label = "DinexFeedback", MainLauncher = true, Icon = "#drawable/icon",Theme ="#style/AppTheme")]
public class MainActivity : Android.Support.V7.App.AppCompatActivity
{
...
Then the project will run fine.
Unhandled Exception: Android.Views.InflateException:
Make sure the necessary nuget package installed in visual studio.
I used card view in my project, i got this issue becoz i didn't install Xamarin.Android.Support.cardview.
so we should install all support nuget package in order to support all widgets here i use card view.
click on project -> Manage Nuget-> check out the installed pakages, if the package were not installed just search the particular package and then download it.
updated on 10/12/2018
check your layout whether all the layout fields are started with capital letter. for ex : In android we used in small letter but In c# we should use otherwise it throws the inflate view exception.

How to remove the padding between preference title and the following preference?

I would like to remove the purple gap in my preference screen:
preference
so that it should look like this:
Google Play Store example
I'm using Xamarin Android and c# to develop my app.
The preference screen is an PreferenceFragmentCompat from Android.Support.V7.Preferences library. The material style is set in my custom theme:
<style name="Theme.DarkTheme" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">#673AB7</item>
<item name="colorPrimaryDark">#512DA8</item>
<item name="colorAccent">#039be5</item><!--#FF4081-->
<item name="colorControlHighlight">#242424</item>
<item name="android:listDivider">#style/android:drawable/divider_horizontal_dim_dark</item>
<item name="preferenceTheme">#style/PreferenceThemeOverlay.v14.Material</item>
Here is how my xml resource file looks like, which I call by AddPreferencesFromResource(Resources.Id.preference_screen) in my PreferenceFragmentCompats OnCreatePreferences() function:
<android.support.v7.preference.PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.v7.preference.PreferenceCategory
android:title="App">
<Preference
android:key="advsettings_preference"
android:title="Erweiterte Einstellungen" />
<Preference
android:key="license_preference"
android:title="Rechtliche Hinweise" />
</android.support.v7.preference.PreferenceCategory>
</android.support.v7.preference.PreferenceScreen>
I already tried to fix it myself by adding padding attributes to PreferenceScreen, but nothing changed.
All the latest NuGet Packages from Xamarin Android are installed (v27.0.2).
Thanks in advance.
Please try set the style like this;
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
...
<!-- Customize your theme here. -->
<item name="preferenceTheme">#style/MyPreferenceStyle</item>
</style>
<style name="MyPreferenceStyle" parent="#style/PreferenceThemeOverlay.v14.Material">
<item name="preferenceCategoryStyle">#style/MyPreferenceCategoryStyle</item>
<item name="android:paddingLeft">10dp</item>
<item name="android:paddingRight">10dp</item>
</style>
<style name="MyPreferenceCategoryStyle" parent="#style/Preference.Category.Material">
<item name="android:layout">#layout/preference_category</item>
</style>
And preference_category.axml:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+android:id/title"
android:textColor="?android:attr/colorAccent"
android:textSize="14dp"
android:fontFamily="sans-serif-medium"
android:paddingStart="16dp"
android:singleLine="true"
android:paddingTop="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
And AppSettings:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.preference.PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.v7.preference.PreferenceCategory
android:title="App">
<Preference
android:key="advsettings_preference"
android:title="Erweiterte Einstellungen"
android:summary="BenachRichtigung"/>
</android.support.v7.preference.PreferenceCategory>
</android.support.v7.preference.PreferenceScreen>
It will resolve the gap issue. And also look similar to your screenshot of Google Play Store. Well, not exactly the same from the Layout Inspector, but similar:
The purple area when looking at your layout with "use layout bounds" in the developer options enabled represent margins, not padding as far as I know.
I suggest trying to make a custom layout for your PreferenceCategory and your Preference's and setting them in your above axml using the android:layout attribute as such:
android:layout="#layout/layout_name"
(Might need to play around with both android:layout and android:widgetLayout attributes)

Android.Views.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class <unknown> error occure for AppCompat

I am getting Binary XML file line #1: Binary XML file line #1: Error inflating class error occure for AppCompat error while trying to add tabbar and toolbar in android.Can anybody help me to come out of it.refering this link AppCompact
Here is my code. This is Style`
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="MyTheme" parent="MyTheme.Base">
</style>
<style name="MyTheme.Splash" parent ="Theme.AppCompat.Light">
<item name="android:windowBackground">#drawable/Splash</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primaryDark</item>
<item name="colorAccent">#color/accent</item>
<item name="android:windowBackground">#color/window_background</item>
<item name="windowActionModeOverlay">true</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#FF4081</item>
</style>
</resources>
This is code in Tabbar.axml and toolbar.axml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TabLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:tabIndicatorColor="#android:color/white"
app:tabGravity="fill"
app:tabMode="fixed" />
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"/>
and main activity
public class FormsActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity//FormsApplicationActivity//
{ protected override void OnCreate (Bundle savedInstanceState)
{
FormsAppCompatActivity.ToolbarResource = Resource.Layout.Toolbar;
FormsAppCompatActivity.TabLayoutResource = Resource.Layout.Tabbar;
base.OnCreate (savedInstanceState);}
`
Try to uninstall the Xamarin.Forms, do a full clean, delete bin/obj folder, restart VS, install back the Xamarin.Forms, rebuild whole solution.

Bind to current binding context?

I have an item template which is to display a List<IGrouping<string, string>>. In order to do this I need to bind an ItemsSource to the current binding context, in WPF I would do it something like {Binding DataContext} how would I do this in MvvmCross?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
local:MvxBind="Text Key"/> !**IGrouping.Key**!
<Mvx.MvxLinearLayout
android:id="#+id/items"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
local:MvxBind="ItemsSource DataContext" !**This doesn't work, should bind IGrouping as IEnumerable<string>**!
local:MvxItemTemplate="#layout/item_myitem"/>
</LinearLayout>
You can bind to the current source by providing an empty path.
To do this, I find the best syntax is just to use "."
<Mvx.MvxLinearLayout
android:id="#+id/items"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
local:MvxBind="ItemsSource ."
local:MvxItemTemplate="#layout/item_myitem"/>
However, some people prefer using an empty string - although I find this a bit less readable
<Mvx.MvxLinearLayout
android:id="#+id/items"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
local:MvxBind="ItemsSource"
local:MvxItemTemplate="#layout/item_myitem"/>
This option - and lots more besides - is discussed in the data-binding article -
https://github.com/slodge/MvvmCross/wiki/Databinding
(Note: empty string binding was broken in nuget v3.0.9 but should be fixed in v3.0.10 - see Error when making bind ObservableCollection<string> for a MvxListView)

MvvmCross MvxHttpImageView error

I'm trying to bind a web image in a listview on Android, using Xamarin.Android and mvvmcross. I'm getting this error though.
MvxBind:Error: 7.13 View type not found - Mvx.MvxHttpImageView
Android.Views.InflateException: Binary XML file line #1: Error inflating class Mvx.MvxHttpImageView
This is my axml...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res/com.mynamespace.android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Mvx.MvxHttpImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/iconeView"
local:MvxBind="{'HttpImageUrl':{'Path':'imageUrl'}}" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="30dp"
local:MvxBind="Text name" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="10dp"
local:MvxBind="Text tagline" />
</LinearLayout>
If you are using v3, then try
MvxImageView instead of MvxHttpImageView
ImageUrl instead of HttpImageUrl
The bound views are in https://github.com/slodge/MvvmCross/tree/v3/Cirrious/Cirrious.MvvmCross.Binding.Droid/Views
I think MvxImageView is also discussed in: http://slodge.blogspot.co.uk/2013/04/n2-lists-and-kittens-n1-days-of.html
You also need to include the MvvmCross File and DownloadCache Plugins, or else you'll get this error
"No IMvxImageHelper registered - you must provide an image helper before you can use a MvxImageView"

Resources