Actionbarsherlock IcsSpinner - the width is always set to the widest positions

I use Actionbarsherlock and want to use my own action bar layout, but still want a navigation list. As a result, I turn on the IcsSpinner widget. However, the width is always large, as the largest element, and this is undesirable. I pulled it out of the action bar for debugging and got the same results:

Short text

enter image description here

Fragment Code

public class TestFragment extends SherlockFragment { private final String[] testStrings = {"Short","Not so long text"}; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view=inflater.inflate(R.layout.test_layout, container, false); IcsSpinner spinner = (IcsSpinner)view.findViewById(R.id.test_spinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), R.layout.spiner_test_row, R.id.spinner_text, testStrings); spinner.setAdapter(adapter); return(view); } } 

test_layout.xml

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <com.actionbarsherlock.internal.widget.IcsSpinner android:id="@+id/test_spinner" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> 

R.layout.spinner_test_row

 <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/spinner_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="16sp" /> 

Switching to the standard Spinner (on the gingerbread emulator) works fine:

enter image description here

enter image description here

Any suggestions?

+4
source share
1 answer

Apparently, this is the default behavior of the IcsSpinner component in ActionBarSherlock, even when the Android version of Honeycomb + is launched. Square wallet on my ICS device.

Jake suggested not using the IcsSpinner component, but without it there is no easy way to use your own action bar layout and maintain the navigation list user interface. If Jake does not and does not offer an alternative, I will continue to use it, making sure that you will fully test future releases of his large library.

-1
source

Source: https://habr.com/ru/post/1438078/


All Articles