spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

How to set correct text size for a Spinner in an Android Toolbar action bar


Try adding the below property to your spinner item, it worked for me :

android:textSize="?attr/actionBarSize"

Hope this helps..

Edit :

Okay, I wasn't telling you about toolbar, let me show an example which might help you :

I assumed in my answer that you have a custom layout defined for spinner, if not then have a look at below code :

Define spinnerLayout.xml file in your layout resource :

<?xml version="1.0"
encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/spinnerLayoutItems"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:textSize="?attr/actionBarSize"  
      
          android:textColor="#FF0000"
          android:gravity="center"/>

Now, add this in your activity :

.....
Spinner spinner = (Spinner)
findViewById(R.id.spinner);   // Your spinner id
in layout.
.....
ArrayAdapter<String> adapter =
ArrayAdapter.createFromResource(this,
                                                  
  R.array.list,R.layout.spinnerLayoutItems);

spinner.setAdapter(adapter);
....

So, I was telling to set your textSize in spinner to "?attr/actionBarSize", you can set it anything, as big as you want.

I am sorry, I by mistake wrote in my previous answer : android:layout_height property, I have corrected it.

Hope this helps....


Categories : Android

Related to : How to set correct text size for a Spinner in an Android Toolbar action bar
Android Spinner Toolbar style
You should make a color state list resource and apply it as background for your CheckedTextView. As for arrow icon being too far, AFAIK it's because of the length of the children, it goes as far as the longest child. So, no way to customize that.

Categories : Android
Dynamically Adding and Removing Spinner from Toolbar in a Fragments
I'm using View.setVisibility(int) to hide a Spinner in my Toolbar based on the current Fragment. @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_menu, menu); switch (getCurrentFragment()) { case FRAGMENT_WITH_SPINNER: mSpinner.setVisibility(View.VISIBLE); break; case FRAGMENT_WITHOUT_SPINN

Categories : Android
Change action bar to toolbar, and now I am having force closes. What am I doing wrong here?
Your code is fine. But you missed app:theme to set toolbar as actionbar. <android.support.v7.widget.Toolbar android:layout_height=”wrap_content” android:layout_width=”match_parent” android:minHeight=”@dimen/triple_height_toolbar” app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> Change the follo

Categories : Android
Get Android to treat HTML Select like Android Spinner?
It is a little bit hacky but it is possible. You have to create a javascript bridge between the WebView and your java code. class JsBridge { @JavascriptInterface public void showNativeSpinner() { // show native spinner logic } } webView.addJavascriptInterface(new JsBridge(), "jsBridge"); In your html code you have to remove/hide the select and add somekind of placeholder that c

Categories : Android
What is the correct JSON to pass to an action which accepts a collection of KeyValuePairs?
If VisualParameter is supposed to be a collection (array) of objects, then you must enclose it in square brackets to make it valid JSON: { "VisualParameter": [ { "Key": "Hello", "Value": 1 }, { "Key": "Hello2", "Value": 2 } ] } You can use jsonlint.com to check whether your JSON is valid.

Categories : Json
Recently Add
I'm trying to create an onListItemClick even for a customized adapter. The array of items is found in res/values folder
No navigation/status bar touch listener exists, why?
z-index in Relative layout
java.lang.SecurityException: Permission Denial: getIntentSender() when using UiAutomation in a test
mvvmcross videoview URL binding
Android Emulator Unfortunately dev tools has stopped
Square Dagger error: class is exclusively members injected / cannot be scoped required
Installing a widget from an APP
How to stop onDraw() methods causing jerky scrolling of a ListView
How to find my Google Play Services Android BASE64_PUBLIC_KEY
Set style programatically does not work
How to get contacts from phonebook and sim but skype, facebook etc. in android
Where to put JUnit test in Android project
My Android Studio project keeps running my old project/application
how to avoid OUtOfMemory problems with create Bitmap
What tools use and how do continuous integration and test in Android with eclipse?
Converting drawable resource to Bitmap Android
Fragment Transaction show() does not show fragment on second time
Espresso - How to match ActionBar visibility?
Viewport setting ignored in Phonegap Android app, but only on certain phones?
how to open an activity with url scheme android
Android AsyncTask and Thread different behavior
How can one ellicit a Toast from a Service to a Fragment
GCMIntentService onRegistered not called
LinearLayout cropping but not expanding in Scrollview
Get a file from the application directory
How to set layout params using view's on touch listener?
How to disable Google Fit and revoke permissions from the app itself
Android Wear - receiving message from Wear without WearableListenerService?
How can I start new activity from another package?
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.