2012-05-08 6 views
2

나는 스피너를 완전히 투명하게하려고 노력하고있다. 안드로이드 4.0에서는 xml 레이아웃 디자이너에서 alpha 속성을 0으로 설정할 수 있습니다. 하지만 Android 2.2에서 작업 할 때 해당 속성을 사용할 수 없으며 Eclipse는 오류로 표시하고 사용할 수 없다고 말해줍니다. Android 2.2 - 어떻게 스피너의 알파 속성을 설정합니까?

은 내가 투명을 writting이 자바 코드를 만들려고 :

final Spinner cmbCategorias = (Spinner) findViewById(R.id.cmbCategorias); 
cmbCategorias.getBackground().setAlpha(0); 

그것은 작동하지만, 회 전자의 텍스트를 볼 수 유지합니다.

누군가 내가 무엇을 할 수 있는지 말할 수 있습니까 ?? 감사

답변

2

만들기 XML 레이아웃 spinner_textview.xml 같은

<?xml version="1.0" encoding="utf-8"?> 
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/txtview" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:ellipsize="marquee" 
    android:singleLine="true" 
    android:textColor="@android:color/transparent" /> 

그리고 자바 코드에 다음을 추가합니다

Spinner sp=(Spinner)findViewById(R.id.sp); 
    sp.setAdapter(new ArrayAdapter(this,R.layout.spinner_textview, 
       items)); 
0

내가 한을이 같은 함수 :

private void enableView(View v, boolean enable) 
{ 
    if(v.isEnabled() == enable) 
     return; 

    float from = enable ? .5f : 1.0f; 
    float to = enable ? 1.0f : .5f; 

    AlphaAnimation a = new AlphaAnimation(from, to); 

    a.setDuration(500); 
    a.setFillAfter(true); 

    v.setEnabled(enable); 
    v.startAnimation(a); 
} 

그것은 스피너에도 적용됩니다.

관련 문제