标签:
PreferenceFragment界面默认是透明的
而其布局代码框架为 <PreferenceScreen> ... </PreferenceScreen>,背景色及透明度属性设置无效,可通过代码中setBackGroundResource实现,代码如下:
public class XXXFragment extends PreferenceFragment implements OnClickListener { @Override public void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); addPreferencesFromResource(R.layout.note_preference_fragment); getPreferenceManager().setSharedPreferencesName("mysetting"); } @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { return true; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); view.setBackgroundResource(R.color.white); return view; } }
参考文章:http://www.crifan.com/android_preferencefragment_transparent_make_ui_messy/
标签:
原文地址:http://www.cnblogs.com/misybing/p/5000148.html