美好的一天
我是Android开发的新手,我正在尝试在主要xml文件中添加2个用于片段的容器,每个容器将使用横向屏幕的一半,但是我尝试的所有方法均无法正常工作,请帮忙。
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.newProject.MainActivity">
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="221dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<FrameLayout
android:id="@+id/fragments_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
谢谢!
最佳答案
我希望这对你有用
对于风景模式
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2"
tools:context=".MainActivity">
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<FrameLayout
android:id="@+id/fragments_container1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>