How to use SearchView in Toolbar Android

You have to use Appcompat library for that. Which is used like below: dashboard.xml <menu 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”> <item android:id=”@+id/action_search” android:icon=”@android:drawable/ic_menu_search” app:showAsAction=”always|collapseActionView” app:actionViewClass=”androidx.appcompat.widget.SearchView” android:title=”Search”/> </menu> Activity file (in Java): public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.dashboard, menu); MenuItem searchItem = menu.findItem(R.id.action_search); SearchManager searchManager = (SearchManager) MainActivity.this.getSystemService(Context.SEARCH_SERVICE); SearchView searchView = null; if (searchItem … Read more

Is it possible to change the textcolor on an Android SearchView?

Add <item name=”android:editTextColor”>@android:color/white</item> to the parent theme and that should change the entered text. You can also use <item name=”android:textColorHint”>@android:color/white</item> to change the hint text color for the SearchView. (Note that you can replace the @android:color/white with whatever appropriate value you’re hoping to use)

Change status bar color with AppCompat ActionBarActivity

I’m not sure I understand the problem. I you want to change the status bar color programmatically (and provided the device has Android 5.0) then you can use Window.setStatusBarColor(). It shouldn’t make a difference whether the activity is derived from Activity or ActionBarActivity. Just try doing: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); … Read more

No shadow by default on Toolbar?

I ended up setting my own drop shadow for the toolbar, thought it might helpful for anyone looking for it: <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_gravity=”top” android:orientation=”vertical”> <android.support.v7.widget.Toolbar android:id=”@+id/toolbar” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:background=”@color/color_alizarin” android:titleTextAppearance=”@color/White” app:theme=”@style/ThemeOverlay.AppCompat.Dark.ActionBar”/> <FrameLayout android:layout_width=”match_parent” android:layout_height=”match_parent”> <!– **** Place Your Content Here **** –> <View android:layout_width=”match_parent” android:layout_height=”5dp” android:background=”@drawable/toolbar_dropshadow”/> </FrameLayout> </LinearLayout> @drawable/toolbar_dropshadow: <?xml version=”1.0″ encoding=”utf-8″?> … Read more

Toolbar and Contextual ActionBar with AppCompat-v7

Update: Solution: use the windowActionModeOverlay property. Set this in your theme: <item name=”windowActionModeOverlay”>true</item> and the actionmode will be shown over the action bar instead of pushing it down. (If you’re not using the latest AppCompat then you need to add the “android:” prefix to the property). It basically lets AppCompat know that you have a … Read more

Add views below toolbar in CoordinatorLayout

Take the attribute app:layout_behavior=”@string/appbar_scrolling_view_behavior” off the RecyclerView and put it on the FrameLayout that you are trying to show under the Toolbar. I’ve found that one important thing the scrolling view behavior does is to layout the component below the toolbar. Because the FrameLayout has a descendant that will scroll (RecyclerView), the CoordinatorLayout will get … Read more

Android API 21 Toolbar Padding

The left inset is caused by Toolbar’s contentInsetStart which by default is 16dp. Change this to 72dp to align to the keyline. Update for support library v24.0.0: To match the Material Design spec there’s an additional attribute contentInsetStartWithNavigation which by default is 16dp. Change this if you also have a navigation icon.

What is the difference between Action Bar and newly introduced Toolbar?

I found a good explanation from Android Developers Blog post. In this release, Android introduces a new Toolbar widget. This is a generalization of the Action Bar pattern that gives you much more control and flexibility. Toolbar is a view in your hierarchy just like any other, making it easier to interleave with the rest … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)