안녕하세요. MainActivity에서 온클릭 이벤트 시에 지정한 레이아웃 프래그먼트로 replace를 시켰는데, 애니메이션을 적용했더니 기존 main 레이아웃에 프래그먼트 레이아웃이 덮어씌워집니다. 왜 이러는걸까요?
MainActivity 입니다
public class MenuActivity extends BaseActivity implements View.OnClickListener{
ImageView imgPremium, imgSelf, imgLibrary, imgSay;
LinearLayout menu_detail;
TextView textPremium, textSelf, textLibrary, textSay;
int mCurrentFragmentIndex;
public final static int FRAGMENT_ONE = 0;
public final static int FRAGMENT_TWO = 1;
public final static int FRAGMENT_THREE = 2;
public final static int FRAGMENT_FOUR = 3;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imgPremium = (ImageView)findViewById(R.id.img_premium);
imgPremium.setOnClickListener(this);
imgSelf = (ImageView)findViewById(R.id.img_self);
imgSelf.setOnClickListener(this);
imgLibrary = (ImageView)findViewById(R.id.img_library);
imgLibrary.setOnClickListener(this);
imgSay = (ImageView)findViewById(R.id.img_say);
imgSay.setOnClickListener(this);
textPremium = (TextView)findViewById(R.id.txt_premium);
textPremium.setOnClickListener(this);
textSelf = (TextView)findViewById(R.id.txt_self);
textSelf.setOnClickListener(this);
textLibrary = (TextView)findViewById(R.id.txt_library);
textLibrary.setOnClickListener(this);
textSay = (TextView)findViewById(R.id.txt_say);
textSay.setOnClickListener(this);
}
public void fragmentReplace(int reqNewFragmentIndex) {
Fragment newFragment = null;
newFragment = getFragment(reqNewFragmentIndex);
// replace fragment
final FragmentTransaction transaction = getSupportFragmentManager()
.beginTransaction();
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
transaction.replace(R.id.menu_frame_layout, newFragment);
// Commit the transaction
transaction.commit();
}
private Fragment getFragment(int idx) {
Fragment newFragment = null;
switch (idx) {
case FRAGMENT_ONE:
newFragment = new PremiumFragment();
break;
case FRAGMENT_TWO:
newFragment = new SelfFragment();
break;
case FRAGMENT_THREE:
newFragment = new LibraryFragment();
break;
case FRAGMENT_FOUR:
newFragment = new SayFragment();
break;
}
return newFragment;
}
public void onClick(View v) {
Intent i;
switch (v.getId()) {
case R.id.img_premium:
case R.id.txt_premium:
mCurrentFragmentIndex = FRAGMENT_ONE;
fragmentReplace(mCurrentFragmentIndex);
getSupportActionBar().show();
break;
case R.id.img_self:
case R.id.txt_self:
mCurrentFragmentIndex = FRAGMENT_TWO;
fragmentReplace(mCurrentFragmentIndex);
getSupportActionBar().show();
break;
case R.id.img_library:
case R.id.txt_library:
mCurrentFragmentIndex = FRAGMENT_THREE;
fragmentReplace(mCurrentFragmentIndex);
getSupportActionBar().show();
break;
case R.id.img_say:
case R.id.txt_say:
mCurrentFragmentIndex = FRAGMENT_FOUR;
fragmentReplace(mCurrentFragmentIndex);
getSupportActionBar().show();
break;
}
프래그먼트 입니다.
public class PremiumFragment extends Fragment{
View v;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
v = inflater.inflate(R.layout.premium_fragment, container, false);
return v;
}
}
아시는 분 부탁드립니다 ..ㅠㅠ