2014-04-16 3 views
1

FragmentTabHost를 만들었지 만 제대로 작동하지만 탭 중력을 오른쪽으로 설정하고 싶습니다. 이 코드를 사용하지만 작동하지 않습니다 어떤 제안을 이해할 수있을 것이다Android - tabWidget의 중력을 설정하는 방법?

<android.support.v4.app.FragmentTabHost 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" >  
    <TabWidget 
     android:id="@android:id/tabs" 
     android:gravity="right" 
     android:layout_gravity="right" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

</android.support.v4.app.FragmentTabHost> 

:

LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, 
LinearLayout.LayoutParams.WRAP_CONTENT); 
     params.gravity = Gravity.RIGHT; 
mTabHost.getTabWidget().setLayoutParams(params); 

내 XML 레이아웃 파일은 다음과 같다!

답변

0

이 코드로 변경하십시오.

<TabWidget 
     android:id="@android:id/tabs" 
     android:gravity="right" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

프로그래밍 방식으로 코드 할 필요가 없습니다.

관련 문제