I want a transparent Toolbar for which I have declared the android:background="@android:color/transparent" attribute.
The problem is that the Toolbar is still having the background color set as my colorPrimary which is #00BCD4.
Here's activity_login_screen.xml file's code:
<?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" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context="com.abc.xyz.LoginScreen"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"> // here is the toolbar. <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@android:color/transparent" app:popupTheme="@style/AppTheme.PopupOverlay"/> </android.support.design.widget.AppBarLayout> <include layout="@layout/content_login_screen"/> </android.support.design.widget.CoordinatorLayout> Here's LoginScreen.java file's code:
public class LoginScreen extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login_screen); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setBackgroundColor(Color.alpha(0)); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); TextView textView = (TextView) findViewById(R.id.text); Typeface typeface = Typeface.createFromAsset(getBaseContext().getAssets(), "fonts/Pacifico.ttf"); textView.setTypeface(typeface; } } Here's styles.xml file's code:
<resources> <!-- 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="colorControlHighlight">@color/colorControlHighlight</item> </style> <style name="AppTheme.NoActionBar"> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> </style> <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/> </resources> Please let me know what is wrong here. Why the Toolbar is not getting transparent background??
Thanks in advance.
No comments:
Post a Comment