开发者

Spinner / Ellipsize / Width

I've a spinner pointing on a CursorA开发者_运维技巧dapter. I set this adapter with a specific view. I would like to fix the spinner's width, I tried a lot of stuff unsucessfully :

  • layout_width="100dp" // to force spinner with a specific size KO
  • reduce the layout width to 100dp // KO
  • use an ellipsize on a textview contained by the adapter // KO

I would like to block the spinner's width. Do you have an idea ?


You could try adding layout_padding to the left and right of it.


You can try creating a custom textview layout for your spinner to fix some properties.

For example, you can fix the width at 100 dp :

<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@android:id/text1"
style="?android:attr/spinnerItemStyle"
android:singleLine="true"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:ellipsize="end" />

Then you can declare it like this:

mSpinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<CharSequence> adapterSpinner = ArrayAdapter.createFromResource(this, R.array.spinner_vals, R.layout.custom_simple_spinner_dropdown_item);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜