叛逆郁郁 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
    关注

    有没有人啊?求解。。。

    评论

报告相同问题?

悬赏问题

  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)