问题:在ViewPager中进行页面滑动后,我的按钮中的文本显示为垂直 .

信息:我有一个ViewPager,显示4个不同的片段 . 一个片段顶部包含3个按钮 . 最初加载片段时,按钮会正确显示 . 但是,当我滑动到另一个片段并向后(2次滑动)时,按钮中的文本将垂直显示 . 我猜测Button的TextView的大小已经改变了 . 另一个奇怪的部分,如果我点击任何按钮,每个按钮中的文字都会正确显示 .

截图:

enter image description here

Attemped:

  • 在onPageSelected(int position)期间使视图无效但没有运气 .

  • 将TextSize设置得更小,非常小!

  • 调用notifyDataSetChanged();

设备:在Android 4.2,4.1和2.3.3上测试都具有相同的效果 .

FragmentWithButtons XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="37dp"
    android:paddingTop="2dp"
    android:gravity="center_horizontal|top" 
    android:background="#FFFFFF">
    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:background="@drawable/tub_01"
        android:text="Map"
        android:textColor="@color/tab_selection"
        android:textSize="14sp" />
    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@id/button1"
        android:background="@drawable/tub_02"
        android:text="List"
        android:textColor="@color/tab_selection"
        android:textSize="14sp"/> 
    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@id/button2"
        android:background="@drawable/tub_03"
        android:text="Filter" 
        android:textColor="@color/tab_selection"
        android:textSize="14sp"/> 
</RelativeLayout>
    ...

与按钮的片段

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View mainView = inflater.inflate(R.layout.buttonFragment, container, false);
    Button button = (Button) mainView.findViewById(R.id.button1)
    button.setOnClickListener(this);
    button = (Button) mainView.findViewById(R.id.button2);
    button.setOnClickListener(this);
    button = (Button) mainView.findViewById(R.id.button3);
    button.setOnClickListener(this);

    return mainView;
}

PageAdapter

public static class LocationPageAdapter extends FragmentPagerAdapter{
    public LocationPageAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public int getCount(){
        return NUM_FRAGMENTS;
    }

    @Override
    public Fragment getItem(int fragID) {
        Log.i(LOGTAG, "Load fragment: " + fragID);
        switch(fragID){
        case 3: return new Fragment1();
        case 1: return new Fragment2();
        case 0: return new Fragment3();
        default: return new FragmentWithButtons();
        }
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object){
    }
}

知道发生了什么或如何解决它?