android 控件透明度设置时setAplha()报空指针的问题

必须在android控件里设置android:background=“”属性否则报空指针

xml代码

<TextView
android:id="@+id/dialog_back"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
/>

java代码

textBack = (TextView) findViewById(R.id.dialog_back);
textBack.getBackground().setAlpha(130);//xml里不设置android:background属性,这里会报空指针错误

posted on 2015-11-05 09:37  阿岳  阅读(661)  评论(0)    收藏  举报

导航