叛逆郁郁 2015-04-21 13:23 采纳率: 0%
浏览 7215

Fragment跳转替换布局错乱问题

小弟在开发中碰到一问题,百思不得其解,业务逻辑是这样的,我在activity中的布局是viewpager和RadioGroup底部菜单,viewpager中填充的是fragment,fragment中有需要跳转另一个fragment,replace新的fragment时,没有覆盖全部的布局,底部的RadioGroup跑到现在fragment的上面了,activity中布局代码

  • <?xml version="1.0" encoding="utf-8"?>
    android:id="@+id/ll_home2"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_weight="1" >

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"/>
    

    android:id="@+id/main_radio"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="bottom"
    android:background="@drawable/bottom_tab_bg"
    android:orientation="horizontal"
    android:paddingTop="2dp"
    >

    <RadioButton
        android:id="@+id/rb_function"
        style="@style/main_tab_bottom"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:drawableTop="@drawable/icon_function"
        android:text="@string/tab_function" />
    
    <RadioButton
        android:id="@+id/rb_orderform"
        style="@style/main_tab_bottom"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:drawableTop="@drawable/icon_orderform"
        android:text="@string/tab_orderform" />
    
    <RadioButton
        android:id="@+id/rb_user"
        style="@style/main_tab_bottom"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:drawableTop="@drawable/icon_user"
        android:text="@string/tab_user" />
    



效果是这样的
图片说明

当我点击listview中的item时要跳转界面
代码是这个
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.ll_home,restaurantContentFragment , "fragment_restaurant");
transaction.addToBackStack("fragment_restaurant");
transaction.commit();

跳转到的fragment布局代码是这样的
<?xml version="1.0" encoding="utf-8"?>
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF" >

<TextView
    android:id="@+id/tv_restaurant_title"
    android:layout_width="fill_parent"
    android:layout_height="55dip"
    android:background="#99FF6600"
    android:gravity="center"
    android:text="风味大酒店"
    android:textSize="22dp" />

<FrameLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@id/tv_restaurant_title"
    android:layout_marginBottom="30dip" >

    <RelativeLayout
        android:id="@+id/rl_resaurant_info_loading"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center" >

        <ProgressBar
            android:id="@+id/pb_resaurant_info_loading"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/tv_resaurant_info_loading"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/pb_resaurant_info_loading"
            android:text="正在加载" />
    </RelativeLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal" >

        <LinearLayout
            android:id="@+id/ll_restaurant_info_class"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:background="#123456"
            android:orientation="vertical" >

            <RadioButton 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="全部类别"
                android:textColor="@drawable/rbn_bg"/>
        </LinearLayout>

        <ListView
            android:id="@+id/lv_menu"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_weight="3" >

        </ListView>
    </LinearLayout>
</FrameLayout>

<LinearLayout
    android:id="@+id/ll_resaurant_info_bottom"
    android:layout_width="fill_parent"
    android:layout_height="30dip"
    android:layout_alignParentBottom="true"
    android:orientation="horizontal">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dip"
        android:layout_weight="3"
        android:gravity="center"
        android:text="已选xxx项,共xxx元"
        android:textColor="#aa0000" />

    <TextView
        android:id="@+id/tv_takeorder"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dip"
        android:layout_weight="1"
        android:text="去下单→"
        android:textColor="#aa0000"
        android:textSize="18dp" />
</LinearLayout>

效果是这样图片说明
RadioGroup到上面去了,不知道是什么问题,求大神帮忙看下

  • 写回答

2条回答

  • 叛逆郁郁 2015-04-21 14:50
    关注

    有没有人啊?求解。。。

    评论

报告相同问题?

悬赏问题

  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常