Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 通货膨胀之后,安卓碎片没有出现_Java_Android_Android Fragments - Fatal编程技术网

Java 通货膨胀之后,安卓碎片没有出现

Java 通货膨胀之后,安卓碎片没有出现,java,android,android-fragments,Java,Android,Android Fragments,我想在活动顶部显示一个片段。这是我现在正在尝试的代码 主课 activity_main.xml fragment_directions.xml 活动本身运行良好;当我触发片段显示时,它通过使用日志和断点运行FragmentTransaction和FragmentView。既然片段被添加到FrameLayout中,为什么不显示片段?提前谢谢 我想这会很有帮助的 尝试在activity_main.xml中交换框架布局和地图视图 您的代码工作正常,但它在地图视图后面,这就是为什么它没有显示 activ

我想在活动顶部显示一个片段。这是我现在正在尝试的代码

主课

activity_main.xml

fragment_directions.xml


活动本身运行良好;当我触发片段显示时,它通过使用日志和断点运行FragmentTransaction和FragmentView。既然片段被添加到FrameLayout中,为什么不显示片段?提前谢谢

我想这会很有帮助的

尝试在activity_main.xml中交换框架布局和地图视图

您的代码工作正常,但它在地图视图后面,这就是为什么它没有显示

activity_main.xml

在片段布局中添加背景色,因为片段已加载但布局透明

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    android:layout_width="match_parent"
    android:background="@android:color/white"
    android:layout_height="match_parent">

    <ListView
        android:id="@+id/directions_listview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        <!-- irrelevant params -->
    />
</android.support.constraint.ConstraintLayout>

可能动画中的淡入淡出错误,或ListView为空或适配器未设置com.mapbox.mapboxsdk.maps.MapView的布局高度和布局宽度是什么相对布局中的最后一项将显示在layout@Fr099y我注释掉了动画部分,仍然不起作用。listview为空应该无关紧要;它至少应该拉出一个空白片段,但它没有t@Sony地图视图的尺寸都是匹配的。这是否意味着我应该将框架布局放在最后?请提供一个。特别是,您给出的代码没有编译,因为没有类或方法。我试过了,仍然不起作用。我甚至试着让FrameLayout的标高高于MapView。我又试了一次,这次让MapView消失了visibility->gone,碎片就出现了。为什么片段没有显示在地图视图的上方?]\只需添加背景色我认为会有用,我只需更新我的ansOh哇,我没有意识到我的测试文本视图实际上显示在透明的背景上。谢谢
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    <!-- irrelevant parameters -->
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <FrameLayout
        android:id="@+id/directions_fragment_framelayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </FrameLayout>

    <com.mapbox.mapboxsdk.maps.MapView>
        <!-- A BUNCH OF CHILDREN -->
    </com.mapbox.mapboxsdk.maps.MapView>
</RelativeLayout>
public class DirectionsFragment extends Fragment {

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_directions, container, false);

        return viewGroup;
    }
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    <!-- irrelevant params -->
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:id="@+id/directions_listview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        <!-- irrelevant params -->
    />
</android.support.constraint.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
        <!-- irrelevant parameters -->
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">


        <com.mapbox.mapboxsdk.maps.MapView>
            <!-- A BUNCH OF CHILDREN -->
        </com.mapbox.mapboxsdk.maps.MapView>

        <FrameLayout
            android:id="@+id/directions_fragment_framelayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        </FrameLayout>

</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    android:layout_width="match_parent"
    android:background="@android:color/white"
    android:layout_height="match_parent">

    <ListView
        android:id="@+id/directions_listview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        <!-- irrelevant params -->
    />
</android.support.constraint.ConstraintLayout>