I am working in android application. Actually there I have to set an image in place of toolbar. But I don't know what the exact sizes of that image.
I am not asking about actionbar size. I googled it a lot but unable to find the solution.
here is my requirement
You can create a custom toolbar and add it to your activity
<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:theme="#style/AppTheme.AppBarOverlay"
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:id="#+id/ivUser"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="#drawable/ic_profile"
android:layout_centerVertical="true"
/>
<ImageView
android:id="#+id/tvTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/ic_logo_light"
android:layout_centerInParent="true"
android:padding="15dp"
/>
<ImageView
android:id="#+id/ivLogout"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="#drawable/ic_logout"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_margin="10dp"
android:visibility="gone"
/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
You can add this toolbar xml to your activity
<include
layout="#layout/toolbar.xml">
Use this toolbar in activity using below code in your activity
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
TextView tvTitle = (TextView) toolbar.findViewById(R.id.tvTitle);
ImageView ivUser = (ImageView) toolbar.findViewById(R.id.ivUser);
ImageView ivLogout = (ImageView) toolbar.findViewById(R.id.ivLogout);
getSupportActionBar().setDisplayShowTitleEnabled(false);
Note: Use NoActionBar theme for the activity. To disable the default toolbar
<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="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
please try this code in your xml file;
<android.support.constraint.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="com.example.kolektif_merta.testapp.MainActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/layout_home_appBarLayout_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="56dp">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize">
</android.support.v7.widget.Toolbar>
</RelativeLayout>
</android.support.design.widget.AppBarLayout>
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout>
And in your java class inside onCreate method(assuming you are in activity);
toolbar = findViewById(R.id.toolbar);
toolbar.setBackground(ContextCompat.getDrawable(this,R.drawable.test));
Here is the test drawable is 1200x640 as you asked.
Also don't forget the update styles.xml file with:
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
Here is the result :
custom toolbar background witm image
Related
I'm trying to achieve AppbarLayout with background, inside the AppbarLayout to have a static Toolbar, under the the Toolbar i'm using a CollpasingToolBar that now contains a Toolbar and later supposed to include also a Custom View that it's content will be scaled according to scrolling position, and in the bottom of the AppBarLayout i'm using a TabLayout.
The issue i can't resolve is: i want that the AppbarLayout Drawable will be also be spread over the status bar, currently i failed to achieve this.
I'm attaching the xml layout and also a screen shot:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:windowDrawsSystemBarBackgrounds = "true"
android:statusBarColor="#android:color/transparent">
<android.support.design.widget.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="220dp"
android:background="#drawable/winterscenery"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsingToolbarLayout"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="180dp"
app:statusBarScrim="#android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
android:fitsSystemWindows="true"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"/>
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="One" />
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Two" />
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Three" />
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/content_text_one" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/content_button" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/content_text_two" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
After editing Manifest file :
<activity android:name=".ExitUntilCollapsedActivity" android:theme="#style/JustTryStyle" />
And creating the JustTryStyle style:
<style name="JustTryStyle" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:navigationBarColor">#android:color/transparent</item>
</style>
I got the following apperance:
In your theme you need to add
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:navigationBarColor">#android:color/transparent</item>
Edit:
Add these two to the theme your activity uses as defined in the AndroidManifest.
If other activities also use use this theme but should not have the transparent navigationbar then you need to extend it and update your AndroidManifest accordingly.
Edit 2: try adding <item name="android:windowTranslucentStatus">true</item> instead or additionally
Edit 3: also add fitSystemWindow=true to constraintlayout and appbar
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>
The image below says it all.
The them I use for this Activity is :
<style name="FormActivityTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
and I'm adding the Toolbar like that in my code :
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.toolbar_underling));
toolbarTitle.setText("TextTitle");
The xml code is :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"
android:layout_width="match_parent" android:layout_height="match_parent"
android:gravity="center_horizontal|center_vertical" >
<android.support.v7.widget.Toolbar android:id="#+id/toolbar_form"
android:gravity="center"
android:background="#color/white" android:minHeight="?attr/actionBarSize"
android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView android:id="#+id/toolbar_form_title" android:layout_gravity="center"
android:textSize="22sp" android:textColor="#color/toolbat_title_color"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</android.support.v7.widget.Toolbar>
<ScrollView
android:layout_margin="#dimen/activity_form_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content">
// more views
</ScrollView>
What am I doing wrong ? Where does the "invisible" toolbar abode my toolbar comes from ? Thank you!
I am using the collapsing Toolbar in a project that I am working on currently. I am setting the title of the collapsing toolbar from my code but the problem is if the title is too big then it overlaps with my menu icons in the toolbar. So how can I fix this issue?
Title OverLaps with menu Icon:
My xml code:
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="205dp"
android:fitsSystemWindows="true"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/agent_profile_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginBottom="87dp"
app:expandedTitleMarginStart="130dp"
app:expandedTitleTextAppearance="#style/expandedappbar"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax">
<ImageView
android:id="#+id/backdrop"
android:layout_width="match_parent"
android:layout_height="170dp"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="#drawable/back" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="170dp"
android:background="#66000000">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="8dp"
android:layout_marginLeft="130dp"
android:orientation="vertical">
<TextView
android:id="#+id/lbl_agent_profile_position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/lbl_agent_profile_Name"
android:layout_marginBottom="5dp"
android:ellipsize="end"
android:maxLines="1"
android:text="Real Estate Professional at Exit Alliance Realty"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#fff"
android:textSize="12sp"
android:typeface="sans" />
<TextView
android:id="#+id/lbl_agent_profile_ibaaxid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#33ffffff"
android:paddingBottom="1dp"
android:paddingEnd="3dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:paddingStart="3dp"
android:paddingTop="1dp"
android:text="iBaax ID : 123456789"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#fff"
android:textSize="12sp"
android:typeface="sans" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/lnr_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
android:background="#fff"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<ImageView
android:id="#+id/img_agent_profile_image"
android:layout_width="110dp"
android:layout_height="110dp"
android:scaleType="centerCrop"
android:src="#drawable/no_profile" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_below="#+id/backdrop"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_toRightOf="#+id/lnr_img"
android:background="#4d6088"
android:paddingEnd="3dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:paddingStart="3dp"
android:text="Write Review"
android:textAllCaps="false"
android:textSize="12sp" />
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
And the code in my activity's OnCreate Method:
setContentView(R.layout.activity_agent_profile2);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//getSupportActionBar().setTitle("Name");
agent = (Agent) getIntent().getSerializableExtra("Agent");
CollapsingToolbarLayout collapsingToolbar =
(CollapsingToolbarLayout) findViewById(R.id.agent_profile_toolbar);
collapsingToolbar.setTitle(agent.name);
I fixed it somehow. I don't why it work though. I had to give separate styles for expandedTitle and collapseTitle with different textSizes. If they were the same textSizes then it would work. Here are my styles below,
<style name="expandedappbar" parent="#android:style/TextAppearance.Medium">
<item name="android:textSize">20sp</item>
<item name="android:textStyle">bold</item>
<item name="android:ellipsize">end</item>
<item name="android:maxLines">1</item>
<item name="android:width">100dp</item>
</style>
<style name="collapseappbar" parent="#android:style/TextAppearance.Medium">
<item name="android:textSize">18sp</item>
<item name="android:textStyle">bold</item>
</style>
and the layout:
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/agent_profile_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginBottom="87dp"
app:expandedTitleMarginStart="130dp"
app:expandedTitleTextAppearance="#style/expandedappbar"
app:collapsedTitleTextAppearance="#style/collapseappbar"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
And screenshot to prove that it works,
Please add option menu for menu items, overlapping issue will not be there
#Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.option_menu, menu);
return true;
}
And set actionBar in activity onCreate:
setSupportActionBar(toolbar)
option_menu.xml
<?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/bt_share"
android:icon="#drawable/ic_send"
android:title="#string/share"
app:showAsAction="always" />
<item
android:id="#+id/bt_suggest_edit"
android:icon="#drawable/ic_menu"
android:title="#string/suggest_an_edit"
app:showAsAction="always" />
</menu>
Collapsed toolbar screenshot
Expanded toolbar screenshot
This doesn't work ?
getSupportActionBar().setTitle("LongTitle");
My solution is listen collapsing progress of CollapsingToolbarLayout. When it totally collapse I disable title of AppBarLayout and set it to activity:
#Override
public void onAppBarOffsetChanged(AppBarLayout appBarLayout, int offset) {
boolean collapsed = offset == appBarLayout.getTotalScrollRange();
collapsingToolbarLayout.setTitleEnabled(!collapsed);
getActivity().setTitle(collapsed ? title : null);
}
I am tying to get transparent toolbar over RecyclerView contains custom Relative Layout i called it customHeader . my layout in the main activity is like:
i use android support design library v.22.2.1 and other support libraries with the same version
things are fine except that, i am getting toolbar with my primary color rather than transparent toolbar even though, i have removed background color from toolbar layout.
this is the result i have got:
What i want is transparent toolbar but should get filled with primary color only when i scroll up
my activity_main layout is:
<android.support.v4.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.support.design.widget.CoordinatorLayout
android:id="#+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsingToolbarLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="#+id/content_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/btnCreate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_marginBottom="#dimen/btn_fab_margins"
android:layout_marginRight="#dimen/btn_fab_margins"
android:src="#drawable/share"
app:borderWidth="0dp"
app:elevation="6dp"
app:pressedTranslationZ="12dp" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="#+id/vNavigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/WHITE"
app:itemIconTint="#color/primary_text"
app:itemTextColor="#color/primary_text"
app:headerLayout="#layout/drawer_header"
app:menu="#menu/drawer_menu"/>
</android.support.v4.widget.DrawerLayout>
then the layout in my fragment is:
<RelativeLayout 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">
<!-- Story list in main page -->
<com.creativeLabs.news.util.MySwipeRefreshLayout
android:id="#+id/swipe_refresh_story"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity$PlaceholderFragment">
<android.support.v7.widget.RecyclerView
android:id="#+id/list_view_story_list"
android:overScrollMode="never"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.creativeLabs.news.util.MySwipeRefreshLayout>
</RelativeLayout>
my customHeader layout is:
<?xml version="1.0" encoding="utf-8"?>
<com.creativeLabs.news.ui.view.SlideTopStory
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginBottom="#dimen/story_list_item_margin_vertical"
android:layout_width="match_parent"
android:layout_height="#dimen/slide_image_height">
<ImageView
android:id="#+id/ivStoryimage"
android:contentDescription="#string/story_title"
android:scaleType="centerCrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<ProgressBar
android:id="#+id/loading_bar"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<!-- A mask view -->
<View
android:background="#drawable/title_slide_background"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="70dip"/>
<View
android:background="#drawable/title_slide_background1"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="70dip"/>
<TextView
android:id="#+id/title"
android:layout_alignParentBottom="true"
android:textColor="#android:color/white"
android:textSize="#dimen/text_size_large"
android:gravity="center_vertical"
android:paddingLeft="#dimen/slide_image_title_padding"
android:paddingRight="#dimen/slide_image_title_padding"
android:paddingEnd="#dimen/slide_image_title_padding"
android:layout_marginBottom="#dimen/slide_image_title_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.creativeLabs.news.ui.view.SlideTopStory>
My app thems.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="colorControlNormal">#android:color/white</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
.......
.......
in the manifest -> application tag:
android:theme="#style/AppTheme.WithoutActionBar">
in my activities and fragments, i coded nothing regarding toolbar colors or any other treatments other than
setSupportActionBar(toolbar);
getSupportActionBar().setHomeButtonEnabled(true);
toolbar.setNavigationIcon(getActionBarIconResource());
so, why toolbar is getting the app primary color? how can i get a transparent toolbar ..any help please?
Thanks in advance
<android.support.v7.widget.Toolbar
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar" />
Check how u style is applied
Where u set it to transparent (alpha?)
View.getBackground().setAlpha(..) ;