我正试图让一个片段出现,就像在我的手机上的android studio中一样。我有一个1440 x 2560像素的三星S7,所以我在Android Studio中选择了Nexus 6渲染选项。
我已经设置了我的片段,以便它包含在名为content_add_edit_recipe.xml
的内容文件中。我的活动activity_add_edit_recipe.xml
包含此文件,如下所示。
<FrameLayout 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:id="@+id/fragment"
android:orientation="vertical"
android:name="com.jcg.grocerylistconverter.AddEditRecipeActivityFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:layout="@layout/fragment_add_edit_recipe"/>
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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.jcg.grocerylistconverter.AddEditRecipeActivity">
这是活动文件:
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_add_edit_recipe"/>
这里是布局标签的片段xml(我认为其余部分现在不相关):
<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:id="@+id/content_add_edit_recipe"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="vertical"
tools:context="com.jcg.grocerylistconverter.AddEditRecipeActivityFragment"
tools:showIn="@layout/activity_add_edit_recipe">....
以下是片段在预览中的外观:
虽然它出现在手机上的方式如下:
我怀疑这与我在启动片段时的实际java代码有关,但在我通过代码追踪膨胀的xmls之后,我无法弄清楚我的生活在何处/如何发生。
如果xmls中没有任何明显的信息,我会发布启动活动/片段的代码,但首先有人可以指出我的xml出现了什么东西吗?
答案 0 :(得分:0)
我认为在设计布局时你并没有考虑文本大小和文本长度。您应该在微调器内测试不同文本长度和大小的布局