Change the icon size in the actionbar - android

I would like to have a bigger action bar.
So I change the action bar size in the style, and now I am looking for changing the icon size and put the text bigger also.
Here is my style :
<!-- Application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:textSize">22sp</item>
<item name="android:actionBarSize">100dp</item>
<item name="android:actionBarTabTextStyle">#style/MyActionBarTabText</item>
<item name="android:actionButtonStyle">#style/MyActionButtonStyle</item>
</style>
<style name="MyActionButtonStyle" parent="android:style/Widget.ActionButton">
<item name="android:layout_width">fill_parent</item>
</style>
<style name="MyActionBarTabText" parent="android:style/Widget.Holo.ActionBar.TabText">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">25dp</item>
</style>
And my menu for the actionBar (menu.xml) :
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/app_setting"
android:title="#string/app_setting"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:icon="#drawable/ic_setting"
android:showAsAction="ifRoom" />
</menu>
And In the main class :
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
return true;
}
Also, I tried several questions, but I was not able to make it work.
I want to change actionbar icon size
How to change actionBar icon size?

The best solution is to implement Toolbar in your layout and put TextView and define attributes on it.
Here is my solution.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay"
tools:ignore="MissingConstraints">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="#style/Theme.MyTest"
app:popupTheme="#style/Theme.MyTest">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_name"
android:textAppearance="#style/TextAppearance.Widget.AppCompat.Toolbar.Title"
android:textColor="#color/white"
android:textSize="#dimen/title_size" />
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/nav_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="#menu/bottom_nav_menu" />
<fragment
android:id="#+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
android:layout_marginTop="?attr/actionBarSize"
app:layout_constraintBottom_toTopOf="#id/nav_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="#navigation/mobile_navigation" />
</androidx.constraintlayout.widget.ConstraintLayout>
Here is styles which used in Toolbar attribute.
values\style.xml
...
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
...
With this way, you will have chance to change the Title color and size as you want.

While importing the icon from Vector Asset, setting the size depending on your requirement will do the job.

Related

android.widget.SearchView not updating with attributes defined in sytle.xml

I am trying to set cursor/hint/icon color of my SearchView in white. Defined the style for it but SearchView is not updating it is showing in black. Kindly suggest what is missing in my code.
styles.xml
<style name="SearchViewStyle" parent="Widget.AppCompat.SearchView.ActionBar" >
<item name="android:textColorPrimary">#color/color_white</item>
<item name="android:textColorHint">#color/color_white</item>
<item name="android:tint">#color/color_white</item>
<item name="queryHint">#string/search_hint</item>
</style>
colors.xml
<color name="color_white">#FFFFFF</color>
SearchView defined in a layout:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary">
<-- other views code -->
<SearchView
style="#style/SearchViewStyle"
android:id="#+id/header_search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="#string/app_name"
android:layoutDirection="rtl"
android:iconifiedByDefault="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:scaleType="centerInside"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
UI on phone screen:
Use androidx.appcompat.widget.SearchView and not SearchView.
SearchView doesn't know what "Widget.AppCompat.SearchView.ActionBar" means.

Android kotlin - Activity with black transparent background and SearchView with white background

As the title says I nedd an activity with black transparent background and a SearchView on top of it with white background and gray/custom text/icon colors.
This is what I have so far:
activity_search_input.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
tools:context=".SearchInput">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/constraintLayout"
android:layout_width="58dp"
android:layout_height="60dp"
android:background="#FFFFFF"
app:layout_constraintEnd_toStartOf="#+id/searchInput"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_back" />
</androidx.constraintlayout.widget.ConstraintLayout>
<SearchView
android:id="#+id/searchInput"
android:layout_width="0dp"
android:layout_height="60dp"
android:background="#FFFFFF"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/constraintLayout"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Even though the background is set to #FFFFFF it is gray!
in manifest:
<activity
android:name=".SearchInput"
android:theme="#style/Theme.AppCompat.Translucent">
</activity>
in styles.xml:
<style name="Theme.AppCompat.Translucent" parent="Theme.AppCompat.NoActionBar">
<item name="android:background">#66000000</item> <!-- Or any transparency or color you need -->
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">#android:style/Animation</item>
</style>
How can I do that? I'm already searching since couple hours for a solution for such a minor thing! Android is absolutely horrendous!
True testing this out was indeed a horrendous experience unless there's an easy method I'm unaware of. Here's a workaround I found for your case.
The main issue is this line <item name="android:background">#66000000</item> in your Translucent style, that messes up the colors which the searchView uses behind the scenes. Remove that and the background you set for searchView should be working now.
But you'll notice all the icons and textcolor remain white you will have to either individually set these with custom icons (for some reason the textColor still wouldn't change) or simply use parent="Theme.AppCompat.Light.NoActionBar" as the parent for your translucent theme.
So now your custom Translucent theme should look like below:
<style name="Theme.AppCompat.Translucent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">#android:style/Animation</item>
</style>
Now since you have removed the window background from theme you will need to set a background to the root layout using android:background="#66000000"
So your activity_search_input.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:background="#66000000"
tools:context=".SearchInput">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/constraintLayout"
android:layout_width="58dp"
android:layout_height="60dp"
android:background="#FFFFFF"
app:layout_constraintEnd_toStartOf="#+id/searchInput"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_back" />
</androidx.constraintlayout.widget.ConstraintLayout>
<SearchView
android:id="#+id/searchInput"
android:layout_width="0dp"
android:layout_height="60dp"
android:background="#FFFFFF"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/constraintLayout"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
The result was this
Tried different ways but this felt the easiest, check if this helps you out, or maybe someone will come up with a better method.

I'm getting a "Error inflating class com.google.android.material.navigation.NavigationView"

I have looked at other posts to this problem and I can't seem to solve it, so I'm hoping that its just a case that I am missing something obvious.
Here is my code:
MainActivity.XML
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
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:fitsSystemWindows="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/translation_panel_blue_open_mea"
android:minHeight="57dp"
android:padding="1dp"
app:layout_constraintTop_toTopOf="parent"
app:subtitleTextColor="#color/header_grey_mea"
app:titleTextColor="#color/header_grey_mea"
android:theme="#style/AppTheme">
</androidx.appcompat.widget.Toolbar>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.navigation.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/AppTheme"
app:menu="#menu/burger_menu" />
</androidx.drawerlayout.widget.DrawerLayout>
burger_menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="#+id/menuLogout"
android:onClick="initUserLogout"
android:title="#string/log_out">
</item>
<item
android:id="#+id/menuItemTutorial"
android:onClick="launchTutorialView"
android:title="#string/tutorial">
</item>
</group>
</menu>
AppTheme
<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="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
and my initBurgerMenufunction that runs in MainActivity:
private fun initBurgerMenu(){
mDrawerLayout = findViewById(R.id.drawer_layout)
val navigationView: NavigationView = findViewById(R.id.nav_view)
navigationView.setNavigationItemSelectedListener { menuItem ->
// set item as selected to persist highlight
menuItem.isChecked = true
// close drawer when item is tapped
mDrawerLayout.closeDrawers()
when (menuItem.itemId) {
R.id.menuLogout -> {
initUserLogout()
}
R.id.menuItemTutorial -> {
Toast.makeText(this, "tutorial", Toast.LENGTH_LONG).show()
}
}
true
}
}
Close your AppBarLayout tag, like this
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="57dp"
android:padding="1dp"
app:layout_constraintTop_toTopOf="parent"
android:theme="#style/AppTheme">
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
Your navigation view in the xml is from com.google.android.material.navigation.NavigationView and you're probably trying to inflate NavigationView from android.support.design.widget, if this is the problem just delete the import and reimport the correct package.
I had the same issue:
This happened after updating various dependencies to latest.
I updated the com.google.android.material:material from 1.4.0-beta01 to 1.7.0-alpha01.
After reverting the version to 1.4.0-beta01 the problem resolved.

toolbar width without menu button

I've created application with menu and toolbar.
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
android:id="#+id/app_bar_menu_coord_layout_included"
layout="#layout/app_bar_menu"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/nav_header_menu"
app:menu="#menu/activity_menu_drawer" />
</android.support.v4.widget.DrawerLayout>
The toolbar (the app_bar_menu_coord_layout_included above):
<?xml version="1.0" encoding="utf-8"?>
<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:id="#+id/app_bar_menu_coord_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:fitsSystemWindows="true"
android:tag="app_bar_menu_coord_layout"
tools:context="com.magnifi.pennantrace.MenuActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#drawable/mybutton"
app:popupTheme="#style/AppTheme.PopupOverlay">
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativelayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--first-->
<TextView
android:id="#+id/toolbar_div_rank"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center"
android:text="4th Place"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#id/guidelineToolbarV1"
app:layout_constraintEnd_toStartOf="#+id/guidelineToolbarH1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
...
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<FrameLayout
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"
android:id="#+id/content_frame"/>
</LinearLayout>
Now I wanted to adjust text sizes of toolbar elements depending on screen size. What I do is take toolbar width as 100% and set the rest of textview's text sizes to fit the desired rectangle (for example 6% of width and 100% of height).
But it seems like its not working properly.
I've tested on screen size 320 height and 480 width:
As you see on the picture, first of all the width of it is 480, and as I noticed the text adjustment doesn't work, take a look on the last text 37M, it should have fitted into one line. What I think is that the menu button (the red rectangle in image) is taking some place. What would be the best way to identify actual width of toolbar without the menu button?
EDIT 1:
I've tried adding to the app_bar_menu_coord_layout_included this:
android:layout_marginLeft="-64dp"
And here is the result of correct text size adjustment. But I don't want to get rid of the menu button. Instead I want to get correct size of toolbar without menu button.
Android gave us components to make ease implementing components. Not for giving hours to customise it. Why don't you make an custom toolbar instead of wasting hours in managing default toolbar.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/toolbar"
style="#style/styleToolbar">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/iv_back"
style="#style/styleToolbarIcon"
android:src="#drawable/ic_back" />
<TextView
android:id="#+id/headerTitle"
style="#style/styleToolbarText"
android:text="#string/app_name" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
some styles to be put in res>values>styles.xml.
<style name="styleToolbar" parent="Widget.AppCompat.Toolbar">
<item name="android:layout_width">match_parent</item>
<item name="android:background">#color/colorWhite</item>
<item name="android:layout_height">?attr/actionBarSize</item>
<item name="colorControlNormal">#color/colorWhite</item>
<item name="android:textColorPrimary">#color/colorWhite</item>
<item name="popupTheme">#style/ThemeOverlay.AppCompat.Light</item>
<item name="theme">#style/MyToolbarTheme</item>
<item name="contentInsetEnd">0dp</item>
<item name="contentInsetLeft">0dp</item>
<item name="contentInsetRight">0dp</item>
<item name="contentInsetStart">0dp</item>
<item name="contentInsetStartWithNavigation">0dp</item>
</style>
<style name="MyToolbarTheme">
<!-- Used to tint the back arrow, menu and spinner arrow -->
<item name="colorControlNormal">#FFF</item>
</style>
<style name="styleToolbarIcon">
<item name="android:layout_width">?attr/actionBarSize</item>
<item name="android:layout_height">match_parent</item>
<item name="android:contentDescription">#string/app_name</item>
<item name="android:padding">#dimen/toolbar_icon_padding</item>
<item name="android:gravity">center</item>
</style>
<style name="styleToolbarText">
<item name="android:layout_width">0dp</item>
<item name="android:textStyle">bold</item>
<item name="android:layout_weight">1</item>
<item name="android:layout_height">match_parent</item>
<item name="android:gravity">left|center_vertical</item>
<item name="android:singleLine">true</item>
<item name="android:textColor">#252525</item>
<item name="android:paddingLeft">10dp</item>
<item name="android:scrollHorizontally">true</item>
</style>
You should customize the toolbar layout as per your need. So you will have all controls on its size.

Unable to run the android app without setting "window no title" to "true"

Something is making my app crash. I am not sure why I need to run a drawing app
my styles.xml file:
<!-- 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>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
this is my styles.xml v21 file
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">true</item>
**<item name="windowNoTitle">true</item>**
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
</resources>
If I set the above to false, my drawing app will crash.
My drawingcontent.xml
<?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/drawing_main"
tools:context=".DrawingActivity">
android:id="#+id/custom_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/toolbar_bottom" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar_bottom"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay"
android:visibility="gone"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin"
android:src="#android:drawable/ic_dialog_email" />
</RelativeLayout>
The other is my drawing_main.xml file
<?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"
android:fitsSystemWindows="true"
tools:context=".DrawingActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar_top"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<com.example.kahheng.smartchat.CustomView
android:id="#+id/custom_view"
android:layout_below="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/toolbar_bottom" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar_bottom"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</RelativeLayout>
Please tell me what wrong with my code and why I must remove the statusbar?
anyone got a idea?
I got code from here
http://www.valokafor.com/android-drawing-app-tutorial-pt-2/
You are using a Toolbar in your XML, and I presume you are using that Toolbar as your ActionBar. Therefore, you can't have another action bar from the theme (there can be only 1 action bar in one activity). So to use the Toolbar as action bar, you have to either use "window no title" or inherit from one of the .NoActionBar themes.

Categories

Resources