What's wrong with this drawable? - android-view

Having a drawable,
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="-90"
android:startColor="#00000000"
android:centerColor="#00000000"
android:endColor="#eefff000"
android:type="linear" />
</shape>
when using as
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/title_bk"
/>
it got an error:
android.view.InflateException: Binary XML file line #45: Binary XML file line #45: Error inflating class <unknown>
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.view.View.inflate(View.java:19790)
but using "#66000000" instead of the drawable it is fine
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#66000000"
/>
Why?

Related

ViewTreeLifecycleOwner not found from Dialog

when I add
<androidx.compose.ui.platform.ComposeView
android:id="#+id/compose_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
to XML I am getting above error. I tried to update appcompat library but it didnt worked.Anyone have sollution?

Is there a syntactic equivalent to <include> in Jetpack Compose Navigation?

<navigation 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:id="#+id/nav_graph"
app:startDestination="#id/fragment">
<include app:graph="#navigation/included_graph" />
<fragment
android:id="#+id/fragment"
android:name="com.example.myapplication.BlankFragment"
android:label="Fragment in Root Graph"
tools:layout="#layout/fragment_blank">
<action
android:id="#+id/action_fragment_to_second_graph"
app:destination="#id/second_graph" />
</fragment>
I want to include graph(destination) As shown above in compose-navigation NavHost.
Is there any way? thanks!

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