android spinner size automatically changed?

android spinner size automatically changed?

By : Adezj
Date : November 18 2020, 03:49 PM
will be helpful for those in need before adapter set. , Specify the layout_width as 0dp for both spinners.
code :

Share : facebook icon twitter icon
Modify the Size of an Android Spinner Drop down part Size?

Modify the Size of an Android Spinner Drop down part Size?

By : Jack Liu
Date : March 29 2020, 07:55 AM
will be helpful for those in need You can not change the size of spinner as it is default widget. But you can make it custom using background image. Here is my code:
code :
    android:drawSelectorOnTop = "true"
       android:src="@drawable/down" />
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    android:width="2dp" />
    android:color="#ECC8EC" />
Automatically Populating a Spinner Based On Previous Spinner - android

Automatically Populating a Spinner Based On Previous Spinner - android

By : Sandeep Rotti
Date : March 29 2020, 07:55 AM
I hope this helps you . you need to move if(parent.getId() == R.id.model_spinner) outside if(parent.getId() == R.id.maufacture_spinner then makesure and call spinnerModel.setOnItemSelectedListener(this) onCreate, to do that you need to move spinnerModel = (Spinner) findViewById(R.id.model_spinner) into your on create, I'd recommend doing the same for all your views, that way you don't call findViewById every time you select a spinner item.
code :
Spinner spinnerManufacture, spinnerModel, spinnerColor;
private ArrayAdapter<String> modelAdapter;
private ArrayAdapter<String> maufactureAdapter;
private ArrayAdapter<String> colorAdapter;

protected void onCreate(Bundle savedInstanceState) {

    spinnerManufacture = (Spinner) findViewById(R.id.manufacture_spinner);
    spinnerModel = (Spinner) findViewById(R.id.model_spinner);
    spinnerColor = (Spinner) findViewById(R.id.color_spinner);

    maufactureAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, Manufacture);
    modelAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item);
    colorAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item);





public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    if (parent.getId() == R.id.maufacture_spinner) {
        String[] model;
        if (spinnerManufacture.getSelectedItem().toString().equals("BMW")){
            model = BMW_Model;
        } else {
            model = new String[] {"not sure what model list to use"};
    if (parent.getId() == R.id.model_spinner) {
        String[] Color;
        if (spinnerModel.getSelectedItem().toString().equals("M3 Coupe")) {
            Color = M3_Color;
        } else if (spinnerModel.getSelectedItem().toString().equals("M5 Sedan")) {
            Color = M5_Color;
        } else {
            Color = new String[] { "not sure what color list to use" };
On configuration changed layout not changed automatically in android

On configuration changed layout not changed automatically in android

By : Sam Mc'Ochieng
Date : March 29 2020, 07:55 AM
wish of those help If you choose to use android:configChanges="orientation|screenSize" then you have manually update the layouts when the screen rotates.
code :
public void onConfigurationChanged(Configuration newConfig)

    if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
public class DetailsFragment extends Fragment
    private EditText ed;

    public static DetailsFragment newInstance(int index)
        return new DetailsFragment();

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        View view = inflater.inflate(R.layout.fragment_layout, container, false);
        ed = (EditText) view.findViewById(R.id.fragment_edit);

        if(null != savedInstanceState)
            //restore the text if null != savedInstanceState -> fragment is recreated

        return view;

    public void onSaveInstanceState(Bundle outState)
        if(null != ed)
            //save the text written in the edittext
            outState.putString("RESTORE_TEXT", ed.getText().toString());

Why spinner size is changed after loading data and text color?

Why spinner size is changed after loading data and text color?

By : Varun Khanna
Date : March 29 2020, 07:55 AM
Does that help When I load data to the spinner from web service using Retrofit, It increase the height of the spinner and change text color. What is the problem? How can I fix it? , To change spinner size: use padding to 0dp
code :
    android:padding="0dp"  //add this
    android:textColor="@android:color/holo_blue_bright" />
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            ((TextView) parent.getChildAt(0)).setTextColor(Color.RED); //change color
            ((TextView) parent.getChildAt(0)).setTextSize(10);  //change size

        public void onNothingSelected(AdapterView<?> parent) {

Creating dynamic spinners and getting value of every spinner, Whenever a spinner item changed, get all spinner values

Creating dynamic spinners and getting value of every spinner, Whenever a spinner item changed, get all spinner values

By : Vinícius Araújo
Date : March 29 2020, 07:55 AM
I wish did fix the issue. First, you need to set same instance of OnItemSelectListener to your all spinners. Let your activity or fragment implement OnItemSelectListener then call spinner.setOnItemSelectListener(this);
In onItemSelected method you can run this code to have selecteds.
code :
    ArrayList<String> selectedList = new ArrayList();

    for (int i = 0; i < dynamicProductProperties.getChildCount(); i++) {
        View view = dynamicProductProperties.getChildAt(i);
        if (view instanceof Spinner){
           String selected = (String) ((Spinner) view).getSelectedItem();
            selectedList.add(TextUtils.isEmpty(selected) ? "" : selected);
Related Posts Related Posts :
  • Android Studio gradle build failed for hello world app
  • Slide a layout up from bottom of screen
  • Play HTML5 video in iOS/Android native media player
  • How to rescale a bitmap file in android?
  • No view found for id 0x for fragment after rotation?
  • Define different themable styles to the same widget types
  • ProGuard not working in my app
  • FragmentTransaction from BaseAdapter
  • Connecting multiple devices in a Wifi Direct group
  • Why TabActivity is deprecated in android
  • How to capture low resolution picture using android camera
  • android preferenceactivity padding in landscape orientation
  • How can I store cookie in webview?
  • Passing variables from one activity to another
  • Create Multicolored Pie Chart in Android Studio
  • how to kill progress dialog in android
  • Show Error on the tip of the Edit Text Android
  • How do I use getWindowManager() by another java file
  • fetching images from gallery on android phones with internal storage
  • How to discover devices like Google TV and Nexus-Q using MediaRoute API on Android?
  • "Unfortunately your app stopped working"- Facebook Integration for Android
  • How to animate button in android?
  • Resource Not Found Exception in class without context or activity
  • Launching Android Netflix App And Passing Video Id
  • Making a Phone Call with a Number Extension
  • NullPointerException at BoringLayout.isBoring is anything but boring
  • java.lang.RuntimeException: Unable to get provider
  • Testing custom Views with Robolectric
  • tools:listheader doesn't work although tools:listitem does
  • oppo, vivo app kill notification not coming in android fcm
  • OnClick Method could not function correctly with if else statement
  • Best method to download image from url in Android
  • How can I open Drawer Layout moving all the view and not just slide over?
  • how to show profile pictures of friends in a list view?
  • Creating TimePickerDialog with custom style in Android
  • Android 2.3.6 support library v7 option menu is missing
  • need of vblank in Display subssytem
  • Android MP4 stream - Video cannot be played
  • FastAdapter: Undo button does not show up after swipe
  • What are reasons to pass getActivity as the LifecycleOwner to the LiveData's observe method in a fragment?
  • Implement Face Recognition in Android
  • Titanium studio cannot run "titanium" command in terminal
  • How to execute command line ffmpeg commands programatically in android?
  • Make Android List Items clickable with each item pointing to a different link
  • listview runs successfully, but nothing is display in emulator
  • How to zoom in a bitmap with high resolution?
  • Passing listView data through intent
  • Google map route direction show by arrows in android v2
  • how to start "uiautomator test run" from android code?
  • Proguard in Android Library
  • Alarm Clock from GIT - Gives error - Android
  • Mock injection using Mockito - Android
  • Get Bitmap from universal image loader
  • Unable to include custom font in android
  • Basics on using logcat in Android development
  • Android: Clear cache programmatically
  • Android: pass object without serialization
  • Can not scroll and click item on gridview inside scrollview
  • Android device keeps disconnecting from adb / eclipse
  • Volley cannot create cache directory. Could not clean up file
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org