如何在不反转所选项目的情况下从左到右反转微调器?

时间:2013-07-28 13:48:17

标签: android android-layout spinner android-xml

Normal Spinner是这样的:

enter image description here

当我尝试使用android:rotationY="180"旋转它时,所选项目也会旋转似乎是合乎逻辑的

enter image description here

现在问题是所选项目被旋转使得所选项目文本无意义

所需的一张与第一张图片相同,但带有旋转的微调器

Spinner XML:

<Spinner  
     android:id="@+id/privacySpinner"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_below="@id/eventPrivacy"     
     android:layout_alignParentRight="@id/eventPrivacy"
     android:prompt="@string/event_privacy"
     android:entries="@array/privacy_levels"         
     android:rotationY="180"
/>

2 个答案:

答案 0 :(得分:0)

保持旋转器上的旋转,但也在用于显示文本的文本视图上添加旋转。

即。将视图指定给所选项目,并将其旋转设置为另一种方式。

伪:

spinner.setAdapter(...);
spinner.setDropDownViewResource(R.layout.my_view);

myView .. setRotationY = 180

REF http://developer.android.com/reference/android/widget/ArrayAdapter.html#setDropDownViewResource(int)

答案 1 :(得分:0)

通过选择'item selected'来解决,因为它被称为视图(textView) 然后将其旋转回来。选中的项目将向后旋转

  privacySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {


                public void onItemSelected(AdapterView<?> adapter, View view, int pos, long id) {

                  if(Locale.getDefault().getLanguage().equals("ar"))
                    view.setRotationY(180);// rotating the view (Selected Item) back 
                public void onNothingSelected(AdapterView<?> arg0) {
                }
            });

        }