当前位置: 代码迷 >> Android >> Fragment切换的时分透明的
  详细解决方案

Fragment切换的时分透明的

热度:14   发布时间:2016-04-28 01:08:57.0
Fragment切换的时候透明的
Fragment切换的时候透明的


切换代码

getFragmentManager().beginTransaction()  
                .addToBackStack("T")  
                .replace(R.id.mainFragment, new TranslationFragment())  
                .commit();

fragment代码

public class TranslationFragment extends Fragment implements OnClickListener {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreateView(inflater, container, savedInstanceState);

View v = inflater.inflate(R.layout.fragment_translation, container,false);
v.setAlpha(1);
v.findViewById(R.id.btnStartTranslationByCode).setOnClickListener(this);
v.findViewById(R.id.btnStartTranslationByXml).setOnClickListener(this);
return v;
}
...
}

------解决思路----------------------

------解决思路----------------------
有没有设置一下R.layout.fragment_translation里的背景颜色试试。
我的自定义fragment,直接定义背景是可以的。
  相关解决方案