2012-03-21 3 views
1

이것은 내 previous question과 유사하지만 Kindle Fire (2.3.4)에서는 작동하지 않습니다.
FragmentTransaction을 사용하여 Fragment를 FrameLayout에 추가했습니다. 조각에서 사용하는 RelativeLayout의 여백을 동적으로 변경하려고합니다.RelativeLayout에 여백을 설정하면 Kindle Fire에서 작동하지 않습니다

그러나 Kindle Fire에서는 FrameLayout.layoutParams로 여백이 변경되지 않습니다. 그러나 이것은 3.2.1에서 작동합니다. 나 또한 setMargins()를 사용하여 시도하고 그것은 작동하지 않았다.

내가 킨들 파이어에서 여백을 동적으로 변경하는 방법을 알고있는 사람이 있습니까?

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 

     View view = inflater.inflate(R.layout.infocard, container, false); 

     RelativeLayout infoLayout = (RelativeLayout) view.findViewById(R.id.info); 
     infoLayout.setOnClickListener(new EmptyClickListener()); 

     final int width = 250; 
     final int height = 270; 
     int leftMargin = 0; 
     int topMargin = 0; 
     FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(width, height); 

     if (x - width < 0) { 
      leftMargin = 0; 
     } else { 
      leftMargin = x - width + 40; 
     } 

     if (y >= 400 && y <= 480) { 
      topMargin = 160; 
     } 

     params.leftMargin = leftMargin; 
     params.topMargin = topMargin; 

     //params.setMargins(leftMargin, topMargin, 0, 0); //this didnt work either 
     infoLayout.setLayoutParams(params); 

     TextView titleView = (TextView) view.findViewById(R.id.titleCard); 
     titleView.setText(title); 

     return view; 
    } 
+0

는 FrameLayout이 나 RelativeLayout의의 서브 뷰 infoLayout가 완벽하게 작동 좋아? –

+0

infoLayout은 RelativeLayout입니다. – heero

+0

왜 RelativeLayout.LayoutParams 대신 FrameLayout.LayoutParams를 사용하고 있습니까? RelativeLayout.LayoutParams를 사용해 보셨습니까? 요점은 params = infoLayout.getParams();를 호출 해 보았습니다. 그런 다음 매개 변수를 다시 작성하는 대신 편집 할 수 있습니까? –

답변

3

내가 다른 RelativeLayout의 내 infoLayout를 래핑하여이 문제를 해결 할 수 있었고, 지금은