Problems getting my ActionModeBar(?) to overlap support toolbar - android

I have been trying to get my app to look more material(ized) with the help of app compat v21, I have replaced my regular actionbar with the support toolbar, and changed my theme to Theme.AppCompat.Light.NoActionBar this works great! However, when I longpress an item in my gridview and my actionmode bar (is that what they are called?) shows up for multi select it shows above the toolbar.
I want it to overlap the toolbar, the same way it did with my old regular actionbar. I have tried to find a solution here, and have found multiple sources saying to add true
This does not work for me, i have tried both with the android: prefix and without, but still I get the same result. My activity extends ActionBarActivity and I have put:
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
In my onCreate. I feel like I have tried anything but I get the same result regardless.
I guess I better show some code:
My main layout
<android.support.v4.widget.DrawerLayout
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
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"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="?window_bg_default"
>
<!-- The main content view -->
<include layout="#layout/toolbar" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
ads:adSize="SMART_BANNER"
android:visibility="gone"
android:background="#color/text_darkgray"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content" />
<TableLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="#+id/main_content"
android:layout_above="#id/adView"
/>
</RelativeLayout>
</LinearLayout>
<!-- The navigation drawer -->
<include layout="#layout/navdrawer" />
My styles
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowActionBarOverlay">true</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="colorPrimary">#color/twee_orange_light</item>
<item name="colorPrimaryDark">#color/twee_orange_dark</item>
<item name="colorAccent">#color/twee_blue_light</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:actionBarStyle">#style/AppTheme.Actionbar</item>
<item name="android:actionModeBackground">#color/twee_orange_dark</item>
<item name="android:actionOverflowButtonStyle">#style/AppTheme.Overflow</item>
<item name="android:homeAsUpIndicator">#drawable/ic_action_home</item>
<item name="card_bg_default">#drawable/img_bg_card</item>
<item name="window_bg_default">#drawable/window_background</item>
<item name="card_episode_name">#color/nextepisodegray</item>
<item name="card_episode_number">#color/twee_black</item>
<item name="button_bg">?android:attr/selectableItemBackground</item>
<item name="button_watched">#drawable/ic_watched_inactive</item>
<item name="text_default">#color/text_slightlydarkgray</item>
<item name="text_default_header">#color/text_darkergray</item>
<item name="text_season_separator">#color/black</item>
<item name="drawer_background">#color/drawer_background</item>
<item name="drawer_list_background">#color/drawer_list_background</item>
<item name="card_bg_default_color">#color/drawer_list_background</item>
<item name="twee_divider">#color/divider_default</item>
<item name="card_header_default">#drawable/img_bg_cardtop_header</item>
<item name="checkbox_watched">#drawable/checkbox_watched</item>
<item name="card_middle_bg">#drawable/background_listitem_default</item>
</style>
My toolbar:
<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_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="#color/twee_orange_light"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
android:elevation="8dp" />
My navdrawer:ยจ
<se.ja1984.twee.Activities.Views.ScrimInsetsScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="#dimen/navigation_drawer_width"
android:layout_height="fill_parent"
android:layout_gravity="left|start"
android:orientation="vertical"
android:id="#+id/drawer_wrapper"
android:background="?drawer_background"
android:fitsSystemWindows="true"
app:insetForeground="#4000"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="165dp"
android:background="#drawable/img_navdrawer_header"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="#dimen/navbar_top"
android:paddingBottom="8dp"
android:id="#+id/lnrProfileChooser"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/layoutImage"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginRight="#dimen/padding_small"
>
<se.ja1984.twee.utils.RoundedImageView
style="#style/Twee_Cast_Photo"
android:layout_height="64dp"
android:layout_width="64dp"
android:id="#+id/imgUser"
android:scaleType="centerCrop"
android:src="#drawable/ic_no_cast"/>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/traktWrapper"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:visibility="gone"
>
<ImageView
android:id="#+id/background"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/trakt_background"
/>
<ImageView
android:layout_gravity="center"
android:id="#+id/imgTraktLogo"
android:layout_width="10dp"
android:layout_height="10dp"
android:src="#drawable/ic_trakt_logo"
/>
</FrameLayout>
</RelativeLayout>
<it.sephiroth.android.library.widget.HListView
android:id="#+id/profiles"
android:layout_width="48dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="right|top" />
</FrameLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="vertical"
android:layout_gravity="bottom"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" android:orientation="vertical"
android:layout_alignParentBottom="true"
>
<TextView
style="#style/Twee_Profile_Displayname"
android:id="#+id/txtUsername"
android:text="#string/profile_notsignedin_displayname"
android:paddingTop="0dp"
/>
<TextView
android:text="Xxxx hours well spent"
style="#style/Twee_Profile_Timewasted"
android:id="#+id/txtTimeWasted"
android:paddingTop="0dp"
android:layout_below="#+id/txtUsername" />
</LinearLayout>
</RelativeLayout>
</FrameLayout>
<LinearLayout
android:id="#+id/navdrawer_items_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:orientation="vertical" />
</LinearLayout>
</se.ja1984.twee.Activities.Views.ScrimInsetsScrollView>
The trained eyes might see that I have borrowed the ScrimInsetScrollView from the IOSched app, but I don't think that matters.
And here's an image of the monsterosity!

I managed to solve this issue myself!
The problem is that I ran my super.onCreate() to late in my onCreate method.
I moved it to the top of my method, and now it works great!

Related

Inner fragment with fitsSystemWindows

I am working on the transparent status bar and bottom navigation bar visible. I have achieved the same with my last question: Gradient status bar with BottomNavigationView
But now, I have a fragments in which fitsSystemWindows is not
working. I have layout like Activity -> Viewpager -> Fragments ->
Viewpager -> child Fragments.
I have gone through many attempts from stack overflow but still no luck :
Appbar fitsSystemWindows - Inside a ViewPager
Android - ViewPager fitsSystemWindows (fullscreen) not working
Setting a child view to fit system windows
Android fitsSystemWindows not working when replacing fragments
How to apply gradient to status bar in android?
I have added this styles :
<item name="android:windowContentOverlay">#null</item>
<item name="windowActionBarOverlay">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:navigationBarColor">#000</item>
<item name="colorControlNormal">#FFFFFF</item>
<item name="colorPrimaryDark">#android:color/transparent</item>
In v21/style :
<item name="colorPrimaryDark">#android:color/transparent</item>
In layout, I have added fitsSystemWindows to each fragment as well as activity.
Activity layout:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<com.mobile.lendlease.views.WrapContentViewPagerBottomTab
android:id="#+id/viewPagerContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/viewDivider"
android:fitsSystemWindows="true" />
<View
android:id="#+id/viewDivider"
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_above="#+id/bottomNavigation"
android:background="#color/default_border" />
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottomNavigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:paddingBottom="#dimen/margin_12"
android:paddingEnd="#dimen/margin_12"
android:paddingStart="#dimen/margin_10"
android:paddingTop="#dimen/margin_10"
app:itemBackground="#color/white"
app:menu="#menu/navigation" />
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
</layout>
One of fragment layout:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbarLayout"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorScreenBackground"
android:focusable="true"
app:elevation="0dp">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="#dimen/toolbar_height"
android:layout_marginBottom="#dimen/margin_20"
android:background="#drawable/toolbar"
android:gravity="bottom"
android:fitsSystemWindows="true"
app:layout_scrollFlags="enterAlways"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingBottom="#dimen/margin_18">
<ImageView
android:id="#+id/ivHome"
android:layout_width="159dp"
android:layout_height="29dp"
android:scaleType="centerInside"
android:src="#drawable/logo" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:orientation="horizontal">
<ImageView
android:id="#+id/ivSearch"
android:layout_width="#dimen/margin_47"
android:layout_height="32dp"
android:contentDescription="#string/app_name"
android:scaleType="fitXY"
android:src="#drawable/ic_search" />
<TextView
android:id="#+id/ivMall"
style="#style/notoSansSemiBoldStyle"
android:layout_width="58dp"
android:layout_height="32dp"
android:layout_marginEnd="#dimen/margin_18"
android:layout_marginStart="#dimen/margin_10"
android:background="#drawable/search_bg_shape"
android:gravity="center"
android:text="#string/mall_all"
android:textAllCaps="false"
android:textColor="#color/gradient_card_color1"
android:textSize="#dimen/font_12"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:minHeight="?attr/actionBarSize"
app:tabBackground="#drawable/tab_indicator_line_selected"
app:tabGravity="center"
app:tabIndicatorColor="#android:color/transparent"
app:tabMode="scrollable"
app:tabSelectedTextColor="#color/colorBlackLight"
app:tabTextAppearance="#style/themeTabText"
app:tabTextColor="#color/colorBlackLight" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/viewPagerContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
</layout>

Make a toolbar with menu icon like amazon app

I am trying to make a toolbar with menu icon like amazon app. But the toolbar menu icon have not set properly. Actually All menu icon has set Left to right. i have need back icon and navigation icon has set on right side, App logo set on center and other icon has set on left side.
menu code...
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
>
<item
android:id="#+id/action_bookmark"
android:icon="#drawable/ic_bookmark_white_24dp"
android:orderInCategory="100"
android:title="#string/action_bookmark"
app:showAsAction="always" />
<item
android:id="#+id/action_back"
android:icon="#drawable/ic_keyboard_arrow_left_white_24dp"
android:orderInCategory="101"
android:title="#string/action_back"
app:showAsAction="always" />
<item
android:id="#+id/texttite"
android:icon="#mipmap/ic_launcher"
android:orderInCategory="102"
android:title="#string/action_forward"
android:titleCondensed="hello........"
app:showAsAction="always" />
<item
android:id="#+id/action_forward"
android:icon="#drawable/ic_keyboard_arrow_right_white_24dp"
android:orderInCategory="103"
android:title="#string/action_forward"
app:showAsAction="always" />
<item
android:id="#+id/action_bookmark1"
android:icon="#drawable/ic_bookmark_white_24dp"
android:orderInCategory="104"
android:title="#string/action_bookmark"
app:showAsAction="always" />
</menu>
I have need this type of toolbar. I try this, but not success. Please Help me...
You can customize the toolbar layout just like any other layouts according to your requirement. Please find below a sample layout just using buttons.
<?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:orientation="vertical">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorBlack">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<Button
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="<" />
<Button
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="=" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Custom"
android:textColor="#color/backgroundColorGenericWhite"
android:textSize="22sp" />
</LinearLayout>
<Button
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="=" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
</LinearLayout>
this is custom toolbar code
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
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="?attr/colorPrimary"
android:padding="0px"
android:layout_margin="0px"
app:popupTheme="#style/AppTheme.PopupOverlay" >
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>

The color of back arrow in Actionbar does not change

The title and back arrow in some activities shown white in some shown black.
I read and applied all the solutions in Stackoverflow but none of them worked.
In some activities code work fine but in some of them no!
My style:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">#drawable/launch_screen</item>
</style>
<style name="NormalTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
In this does not work :
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="de.h_da.pizzaorder.Activities.NewUserActivity"><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/NewUserActivity_Toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay"
/>
</android.support.design.widget.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="top"
android:scrollbars="vertical"
>
<TextView
style="#style/TextView"
android:text="#string/NewUserActivity_Username_TextView" />
<EditText
android:id="#+id/NewUserActivity_Username_EditText"
style="#style/EditText"
android:hint="#string/NewUserActivity_HintUsername_EditText"
android:maxLength="40"/>
<TextView
android:id="#+id/NewUserActivity_Password_TextView"
style="#style/TextView"
android:text="#string/NewUserActivity_Password_TextView" />
<EditText
android:id="#+id/NewUserActivity_Password_EditText"
style="#style/EditText"
android:hint="#string/NewUserActivity_HintPassword_EditText"
android:inputType="textPassword"
android:maxLength="45"/>
<TextView
android:id="#+id/NewUserActivity_RePassword_TextView"
style="#style/TextView"
android:text="#string/NewUserActivity_RePassword_TextView" />
<EditText
android:id="#+id/NewUserActivity_RePassword_EditText"
style="#style/EditText"
android:hint="#string/NewUserActivity_HintRePassword_EditText"
android:inputType="textPassword"
android:maxLength="45"/>
<TextView
style="#style/TextView"
android:text="#string/NewUserActivity_Name_TextView" />
<EditText
android:id="#+id/NewUserActivity_Name_EditText"
style="#style/EditText"
android:hint="#string/NewUserActivity_HintName_EditText"
android:maxLength="40"/>
<TextView
style="#style/TextView"
android:text="#string/NewUserActivity_Family_TextView" />
<EditText
android:id="#+id/NewUserActivity_Family_EditText"
style="#style/EditText"
android:hint="#string/NewUserActivity_HintFamily_EditText"
android:maxLength="40"/>
<TextView
style="#style/TextView"
android:text="#string/NewUserActivity_Email_TextView" />
<EditText
android:id="#+id/NewUserActivity_Email_EditText"
style="#style/EditText"
android:hint="#string/NewUserActivity_HintEmail_EditText"
android:inputType="textEmailAddress"
android:maxLength="40"/>
<TextView
style="#style/TextView"
android:text="#string/NewUserActivity_Telephone_TextView" />
<EditText
android:id="#+id/NewUserActivity_Telephone_EditText"
style="#style/EditText"
android:hint="#string/NewUserActivity_HintTelephone_EditText"
android:inputType="phone"
android:maxLength="13"/>
<TextView
style="#style/TextView"
android:text="#string/NewUserActivity_Address_TextView" />
<EditText
android:id="#+id/NewUserActivity_Address_EditText"
style="#style/EditText"
android:maxLength="500"
android:scrollbars="vertical"
android:hint="#string/NewUserActivity_HintAddress_EditText"
android:layout_height="match_parent"
android:imeOptions="actionDone"/>
<Button
android:id="#+id/NewUserActivity_Create_Button"
style="#style/Button"
android:text="#string/NewUserActivity_Create_Button" />
</LinearLayout>
</ScrollView>
</LinearLayout>
in this work:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="de.h_da.pizzaorder.Activities.SettingsActivity">
<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/SettingsActivity_Toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<ListView
android:id="#+id/SettingsActivity_ListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#null"/>
</LinearLayout>
To make your toolbar "back" arrow and overflow icon light, while maintaining a light themed popup menu:
Add a toolbar style in your style.xml file(s):
<style name="AppTheme.Toolbar" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="popupTheme">#style/ThemeOverlay.AppCompat.Light</item>
<item name="theme">#style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
</style>
Set the new style to your Toolbar layout:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
style="#style/AppTheme.Toolbar"/> <!-- Added style -->
This will give your Toolbar a dark themed (white) arrow and overflow icon, but will keep your popup menu light.
Taken from (original link) here: https://stackoverflow.com/a/33833931/2905354
This works perfectly and has the added benefit of making your app easier to theme.
I faced this problem, I just tried to set my own drawable as back button like this :
final Drawable your_drawable = getResources().getDrawable(R.drawable.back_arrow);
upArrow.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
getSupportActionBar().setHomeAsUpIndicator(your_drawable);

Elevation / shadow not working on my app

I'm creating an android app for our capstone project. I'm using API 23. I add elevation on my toolbars and other components yet the shadows aren't appearing. Is my theme ruining it?
<!-- Base application theme. -->
<style name="ThesisTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- 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:colorButtonNormal">#color/colorButton</item>
<item name="android:textColorPrimary">#color/textColorPrimary</item>
<item name="android:statusBarColor">#color/colorPrimaryDark</item>
<item name="android:navigationBarColor">#color/colorPrimary</item>
<item name="colorControlNormal">#c5c5c5</item>
<item name="colorControlActivated">#color/colorAccent</item>
<item name="colorControlHighlight">#color/colorPrimaryDark</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<!--Datepicker-->
<item name="android:datePickerDialogTheme">#style/MyDatePickerDialogTheme</item>
</style>
when i try to include the toolbar then run the program to my phone/ emulator the shadow wont display. even with cardview
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/activity_login"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="capstoreit.capstoreit.Login.Login"
android:background="#drawable/login_bg">
<!--Layout for Login and Signup-->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:elevation="10dp"
android:layout_height="wrap_content">
<!--Toolbar-->
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="#+id/login_toolbar"
android:layout_width="match_parent"
android:elevation="10dp"
local:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
local:popupTheme="#style/ThemeOverlay.AppCompat.Light"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/new_logo"
android:adjustViewBounds="true"
android:padding="5dp"
android:id="#+id/app_logo" />
</android.support.v7.widget.Toolbar>
<!--Tab-->
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed"
app:tabGravity="fill"
android:elevation="10dp"
android:background="#color/textColorPrimary"
app:tabSelectedTextColor="#color/colorAccent"
/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.8"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_alignParentStart="true"
>
</android.support.v4.view.ViewPager>
<ImageView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.2"
/>
</LinearLayout>
</RelativeLayout>
Screenshot:
After changing to app:elevation
I was able to fix my erro by removing this on my Android Manifest:
android:hardwareAccelerated="false"
use this if you are using support library for older versions too
app:elevation
use this if you are not using support library
android:elevation

Android Material CardView with full screen image on Cardview

i need to do this :
http://developer.android.com/design/material/images/card_travel.png
so i create and add the dependency to the project and here is my activity main code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/feed_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_margin="6dp">
<ImageView
android:layout_width="100dp"
android:layout_height="50dp"
android:src="#drawable/ic"/>
<TextView
style="#style/TextAppearance.AppCompat.Caption"
android:textColor="#555"
android:layout_margin="3dp"
android:gravity="end"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Detail"/>
</android.support.v7.widget.CardView>
</LinearLayout>
so, how we can do this like below picture:?
http://i.stack.imgur.com/Z0lNa.png
Cheers!
What you're looking for is a translucent status bar. When you have this configured you're able achieve this effect. Make also sure to remove the actionbar as I do in my example down below, otherwise you'll have to make it transparent.
Change your v21/themes.xml file to this:
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
Then add android:fitsSystemWindows="true" to your LinearLayout.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/feed_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">

Categories

Resources