I have this error when i start Activity with Layout in Xamarin.Android project. How to fix this?
All android nuget packages v. 28.0.0.3
Android.Views.InflateException: 'Binary XML file line #1: Binary XML file line #1: Error inflating class android.suppot.design.widget.NavigationView'
XAML
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="#+id/drawerLayout"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<include
layout="#layout/include_main"
/>
</LinearLayout>
<android.suppot.design.widget.NavigationView
android:id="#+id/navView"
android:layout_height="match_parent"
android:layout_width="300dp"
android:background="#android:color/white"
android:layout_gravity="start"
app:headerLayout="#layout/headerlayout"
app:menu="#menu/navmenu"
/>
</android.support.v4.widget.DrawerLayout>
NavMenu
<?xml version="1.0" encoding="utf-8" ?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group>
<item
android:id="#+id/navProfile"
android:title="Профиль"
android:icon="#mipmap/ic_person"/>
<item android:id="#+id/navPayments"
android:icon="#mipmap/ic_wallet"
android:title="Транзакции"/>
<item android:id="#+id/navHistory"
android:title="История"
android:icon="#mipmap/ic_history"
/>
<item
android:id="#+id/navPromo"
android:title="Промо"
android:icon="#mipmap/ic_discount"
/>
<item
android:id="#+id/navSupport"
android:title="Поддержка"
android:icon="#mipmap/ic_support"
/>
<item
android:id="#+id/navAbout"
android:title="О нас"
android:icon="#mipmap/ic_about"
/>
</group>
</menu>
Include_main
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rootView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Main Layout"
android:textSize="20sp"
android:gravity="center"
android:layout_gravity="center"
/>
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
header_layout
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#android:color/white"
android:theme="#style/ThemeOverlay.AppCompat.Dark">
<Refractored.Controls.CircleImageView
android:id="#+id/accoutImage"
android:layout_height="100dp"
android:layout_width="100dp"
android:layout_gravity="center"
android:src="#drawable/account"
android:scaleType="centerCrop"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/accountTitle"
android:layout_gravity="bottom"
android:gravity="center"
android:text="UserName"
android:layout_marginBottom="12dp"
/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_gravity="bottom"
android:background="#android:color/holo_blue_dark"/>
</FrameLayout>
styles.xml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="Theme.Splash"
parent="Theme.AppCompat.NoActionBar">
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">#drawable/splash</item>
</style>
<style name="Theme.Register" parent="Theme.AppCompat.NoActionBar">
<item name="windowNoTitle">true</item>
</style>
<style name="MainTheme" parent="MainTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette ->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#color/colorPrimary</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#color/colorAccent</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">#style/AppCompatDialogStyle</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#color/colorAccent</item>
</style>
</resources>
You have misspelled the word support. Just try to replace
<android.suppot.design.widget.NavigationView>
with
<android.support.design.widget.NavigationView>
Besides, make sure the nuget:Refractored.Controls.CircleImageView have been installed, otherwise the code will report the error as well.
Note:
I have tested that It doesn't matter if the namespace is Refractored.Controls.CircleImageView or refractored.controls.CircleImageView.They all works.
try to change refractored.controls.CircleImageView instead of Refractored.Controls.CircleImageView in your header_layout :
<refractored.controls.CircleImageView
android:id="#+id/accoutImage"
android:layout_height="100dp"
android:layout_width="100dp"
android:layout_gravity="center"
android:src="#drawable/account"
android:scaleType="centerCrop"
/>
and :
<android.support.design.widget.NavigationView>
instead of:
<android.suppot.design.widget.NavigationView>
Related
I want to add shadow to my custom dialog. But how to remove this white border? Help me please)
<?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:minWidth="300dp"
android:background="#android:drawable/dialog_holo_light_frame"
android:orientation="vertical" >
<TextView
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="20dp"
android:background="#color/brown"
android:gravity="top|center"
android:text=""
android:textColor="#color/white" />
...
</LinearLayout>
Add custom style
<style name="Theme.CustomDialog" parent="#android:style/Theme.Translucent.NoTitleBar">
<item name="android:windowIsFloating">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:padding">10dp</item>
<item name="android:background">#ff90ff90</item>
I'm trying to use NavigationView to implement NavigationDrawer. I have added the separator by setting group id in menu. However I can't see the separator. I guess it is because the separator color is same as the background. So I want to change the separator color. But I find no way to change it. Can anyone help me?
In screenshot, it seems have a room for separator between History and Settings, but you can't see it.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
tools:context=".ui.MapActivity">
<LinearLayout
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="#layout/toolbar_actionbar" />
<!--main content-->
</LinearLayout>
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/navdrawer_background"
app:insetForeground="#4000"
app:itemTextColor="#color/navdrawer_item_text_color"
app:itemIconTint="#color/navdrawer_item_icon_tint"
app:headerLayout="#layout/drawer_header"
app:menu="#menu/drawer"/>
</android.support.v4.widget.DrawerLayout>
drawer.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:id="#+id/group_feature"
android:checkableBehavior="single">
<item android:id="#+id/navdrawer_item_map"
android:checked="true"
android:icon="#drawable/ic_drawer_map"
android:title="#string/navdrawer_item_map"/>
<item android:id="#+id/navdrawer_item_favourite"
android:icon="#drawable/ic_drawer_fav"
android:title="#string/navdrawer_item_fav"/>
<item android:id="#+id/navdrawer_item_history"
android:icon="#drawable/ic_drawer_history"
android:title="#string/navdrawer_item_history"/>
</group>
<group android:id="#+id/group_settings"
android:checkableBehavior="single">
<item android:id="#+id/navdrawer_item_settings"
android:icon="#drawable/ic_drawer_settings"
android:title="#string/navdrawer_item_settings"/>
<item android:id="#+id/navdrawer_item_help"
android:icon="#drawable/ic_drawer_help"
android:title="#string/navdrawer_item_help"/>
<item android:id="#+id/navdrawer_item_about"
android:icon="#drawable/ic_drawer_about"
android:title="#string/navdrawer_item_about"/>
</group>
</menu>
just apply following line on style.xml
<item name="android:listDivider">your_color</item>
The below is just information for your knowledge ...
If you have seen design support library .. they are using following layout for NavigationView seprator..
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"/>
</FrameLayout>
here, you can see android:background="?android:attr/listDivider" ..
So enjoy ...
and here is my output that i change color to holo_blue
Here is best and easy way while using menu as view
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:theme="#style/ThemeToolbar.NavigationView"
app:itemTextColor="#color/white"
app:itemIconTint="#color/white"
app:headerLayout="#layout/activity_home_nav_header"
app:menu="#menu/activity_home_drawer" />
ThemeToolbar.NavigatinoView
<style name="ThemeToolbar.NavigationView" >
<item name="android:listDivider">#color/white</item>
<item name="android:textColorSecondary">#color/white</item>
</style>
Create a style in your styles.xml. Enter your preferred color in the android:listDivider
<style name="NavigationView" parent="Base.Theme.AppCompat">
<item name="android:listDivider">#color/text_lightgray</item>
</style>
Reference the style as the theme of your navigation view:
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="false"
android:theme="#style/NavigationView"
app:headerLayout="#layout/nav_header"
app:menu="#menu/drawer_view"
app:itemTextColor="#color/text_white"/>
Lastly, make sure that the groups inside your menu have unique ids. If your groups do not have the id attribute, this won't work!
<group android:checkableBehavior="single"
android:id="#+id/group1">
<item
android:id="#+id/item1"
android:title="#string/item1" />
</group>
<group android:checkableBehavior="single"
android:id="#+id/group2">
<item
android:id="#+id/item2"
android:title="#string/item2" />
</group>
<!-- 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>
<item name="android:textColorPrimary">#color/menu_text_color</item>
<item name="android:textColorSecondary">#color/menu_text_color</item>
</style>
textColorPrimary changes the color of the header.
Perfect answer:
<android.support.design.widget.NavigationView
android:id="#+id/activity_principal_nav_view"
android:layout_width="#dimen/size_230"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/black"
android:fitsSystemWindows="true"
app:insetForeground="#color/white"
app:menu="#menu/settings_menu"
app:itemTextColor="#color/white"
app:itemIconTint="#color/white"
app:headerLayout="#layout/settings_menu_header"
android:theme="#style/NavigationDrawerStyle"/>
Divider Color Is Changed
STEP 1:
Create list_divider.xml file in your drawable folder.
copy and paste the following lines into your list_divider.xml.
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="#dimen/_16sdp"
android:insetRight="#dimen/_16sdp">
<shape>
<solid android:color="#FFFFFF" />
<size android:height="2dp" />
</shape>
</inset>
STEP 2:
Add this line to your Main Theme ( Theme Mentioned in your AndroidManifest.xml file)
<item name="android:listDivider">#drawable/list_divider</item>
For Example
<style
name="MyMaterialTheme.Base"
parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:listDivider">#drawable/list_divider</item>
<item name="android:listDivider">#drawable/list_divider</item>
STEP 3:
No Change required in NavigationView for divider Color
<com.google.android.material.navigation.NavigationView
android:id="#+id/navigationView"
android:layout_width="#dimen/nav_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="?attr/colorPrimary"
app:headerLayout="#layout/header_navigation_drawer"
app:itemIconTint="?attr/nav_drawer_icon_color"
app:itemTextColor="?attr/nav_text_color"
app:menu="#menu/navigation_drawer_list_menu"
tools:ignore="MissingConstraints" />
I have a SwitchCompat in the action bar (v7.Toolbar) of my activity. I want it be colorStructure when off and colorAccent when on. It works fine on pre-Lollipop, but on Lollipop the activated switch is drawn in a color which I did not define anywhere. It looks like "material_deep_teal_200". Thats my only style definitions:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Default" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<!--<item name="android:windowNoTitle">true</item>-->
<item name="windowActionBar">false</item>
<item name="colorSwitchThumbNormal">#color/colorStructure</item>
<item name="colorControlNormal">#color/colorPrimary</item>
<item name="colorControlActivated">#color/colorAccent</item>
<item name="colorControlHighlight">#color/colorAccent</item>
<!--<item name="selectBarStyle">#style/DefaultSelectBar</item>-->
</style>
</resources>
And that's the begin of the activity xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:theme="#style/Widget.AppCompat.Toolbar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
android:background="#color/colorPrimary"
android:paddingRight="#dimen/abc_dropdownitem_text_padding_right">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingRight="#dimen/abc_action_bar_icon_vertical_padding_material">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/helpButton"
android:src="#drawable/ic_help_large"
android:background="#00000000"
android:layout_gravity="center"/>
<android.support.v7.widget.SwitchCompat
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/master_switch"
android:clickable="true"
android:checked="true"
android:gravity="center"
android:layout_gravity="right"
/>
</FrameLayout>
</android.support.v7.widget.Toolbar>
So what do I need to change to make the switch have the same custom colors on KitKat and Lollipop?
Thanks
Actually the code as presented above works fine - also on Lollipop. I must have done a mistake during validation after cleaning up the problematic code.
Originally the problem was when I also had a configuration in values-v21. I assume that there was a typo or something like that which got lost when I was simplifying all into the default xml file.
So in short, the code as presented works, and I assume that having configurations in values-v21 would not cause a problem either.
I want to separate data of two columns in a List View by a line or any block, as shown here
I tried following solutions, unfortunately they did not work
Solution 1
Solution 2
Please check code for my application and correct me if i missed any thing
Main Activity XML
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" tools:context=".Time" android:background="#color/accent_material_dark" android:orientation="horizontal">
<TextClock android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="#+id/textClock" android:layout_gravity="center_vertical" android:format24Hour="#android:string/yes" />
</LinearLayout>
Row Layout XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:orientation="horizontal" android:layout_height="fill_parent" android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="#+id/rowTextView1" style="#style/clock1"></TextView>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="#+id/rowTextView2" style="#style/clock2"></TextView>
</RelativeLayout>
Styles XML
<resources>
<!-- Clock application theme. -->
<style name="clock1">
<!-- Customize your theme here. -->
<item name="android:background">#24598a</item>
<item name="android:padding">10dp</item>
<item name="android:textSize">16sp</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_alignParentLeft">true</item>
</style>
<style name="clock2">
<!-- Customize your theme here. -->
<item name="android:background">#24598a</item>
<item name="android:padding">10dp</item>
<item name="android:textSize">16sp</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_alignParentRight">true</item>
</style>
<style name="AppTheme" parent="android:style/Theme.Holo.Light.DarkActionBar"></style>
</resources>
try this example layout code for your list item view
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#color/white"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="#+id/divider"
android:gravity="left|center_vertical"
android:text="Some data info" />
<View
android:id="#+id/divider"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_toLeftOf="#+id/clockInfo"
android:background="#android:color/black" />
<TextView
android:id="#+id/clockInfo"
android:layout_width="60dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:gravity="center"
android:text="11:11" />
</RelativeLayout>
I want to build a theme for my app. But it seems like my LiestView item don't apply the values.
This is the styles.xml:
<style name="AppTheme" parent="android:Theme.Holo.Light">
<item name="android:textViewStyle">#style/TextView</item>
</style>
<style name="TextView" parent="android:Widget.TextView">
<item name="android:layout_margin">8dp</item>
<item name="android:padding">0dp</item>
<item name="android:textColor">#87000000</item>
<item name="android:textSize">18sp</item>
</style>
in my activity i use a Listview with Custom Adapter but the TextViews from my item.xml did'nt have a margin:
<LinearLayout 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:clickable="true"
android:orientation="vertical"
tools:context="de.resper.enigma2chromecast.mainLive" >
<TextView
android:id="#+id/channelName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="#string/hello_world" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/hello_world"
android:id="#+id/channelLine1"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
</LinearLayout>
what ever you designed xml, put in android manifest file in application theme
<application android:theme="#style/CustomTheme">