Android 如何在layout land文件夹中使用fragment_main.xml?
我创建了一个简单的应用程序,它自动生成activity\u main.xml和frugmented\u main.xml文件 我创建了新文件夹“布局栏”,并添加到“res”文件夹下(布局和布局res文件夹处于同一级别)。然后,我在layoutland文件夹下创建了另一个fragmented_main.xml文件,该文件具有相同的id和其他内容 但这个有问题的应用程序在纵向定位方面工作得非常好。但它突然停止了。我不知道为什么。我是否应该采取更多措施来解决此问题。请帮我解决这个问题 这里是activity_main.xml和片段_main.xml文件的代码 activity_main.xmlAndroid 如何在layout land文件夹中使用fragment_main.xml?,android,android-layout,android-fragments,Android,Android Layout,Android Fragments,我创建了一个简单的应用程序,它自动生成activity\u main.xml和frugmented\u main.xml文件 我创建了新文件夹“布局栏”,并添加到“res”文件夹下(布局和布局res文件夹处于同一级别)。然后,我在layoutland文件夹下创建了另一个fragmented_main.xml文件,该文件具有相同的id和其他内容 但这个有问题的应用程序在纵向定位方面工作得非常好。但它突然停止了。我不知道为什么。我是否应该采取更多措施来解决此问题。请帮我解决这个问题 这里是activ
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ds.mali.MainActivity"
tools:ignore="MergeRootFrame" />
fragmented_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.ds.mali.MainActivity$PlaceholderFragment" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Count is 0"
android:textSize="40sp" />
<Button
android:id="@+id/btn1"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="39dp"
android:onClick="addOne"
android:text="Add One" />
<Button
android:id="@+id/btn1"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="96dp"
android:onClick="subOne"
android:text="Substract One" />
</RelativeLayout>
这里是布局土地文件夹中的frgmaned_main.xml
<?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"
tools:context="com.ds.mali.MainActivity$PlaceholderFragment" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Count is 0"
android:textSize="40sp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100" >
<Button
android:id="@+id/btn1"
android:layout_height="wrap_content"
android:layout_weight="50"
android:onClick="addOne"
android:text="Add One" />
<Button
android:id="@+id/btn1"
android:layout_height="wrap_content"
android:layout_weight="50"
android:onClick="subOne"
android:text="Substract One" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Welcome to landscape View " />
</LinearLayout>
在活动标签中添加此代码
android:configChanges="orientation|screenSize"
例如:
<activity
android:name="com.world.nanomap.PathGoogleMapActivity"
android:configChanges="orientation|screenSize"
android:label="Route Map" >
</activity>
在layout land
以及layout port
文件夹中添加fragmented_main.xml
,这将解决您的问题。如果可能的话,发布堆栈跟踪以了解确切原因我创建了layout land文件夹并添加了碎片_main.xml文件。。那么肖像版也不行。那么如何解决呢现在只有logcat堆栈跟踪告诉我们确切的原因。因此,在你的问题中发布你的logcat堆栈跟踪。我是编程新手。在哪里可以找到活动标签?谢谢。。问题解决了。。我会在2分钟后选择这个作为最佳答案