Mat*_*ley 6 android android-fragments
我有一个非常奇怪的问题,我有一个时间锻炼的魔鬼.
我有一个片段,我添加到RelativeLayout(尝试过LinearLayout和FrameLayout),动态填充文本内容.
如果文本内容太大,则片段在渲染后消失.我通过限制内容长度来验证这一点,在这些情况下它很好.
这个问题似乎只发生在我见过的三星Galaxy S4上.
在将它们添加到View时,S4系统中是否存在限制片段高度的错误?
我用来添加片段的代码是:
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
mFragment = new DisplayFragment();
fragmentTransaction = fragmentTransaction.add(R.id.patient_container, mFragment, mFragment.getClass().getName());
fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
fragmentTransaction.commit();
Run Code Online (Sandbox Code Playgroud)
此代码适用于我测试的所有设备以及除Galaxy S4之外的所有模拟器实例.如果视图高度超过设定限制(不确定这是什么),它只会在S4上中断.
发生此问题时,我收到以下控制台警告:
E/ViewSystem?查看#1 mHardwareLayer无效.
任何有关这方面的帮助将非常感激.
提前致谢
更新:添加了片段XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rootLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@android:color/white"
android:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:background="@android:color/white"
android:gravity="top">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Patient's name:"
style="@style/bodyText"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/placeholder_text"
android:id="@+id/patientsNameTextView"
android:gravity="right"
style="@style/blueBodyText"
/>
</LinearLayout>
<View style="@style/hr"
android:layout_margin="0dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="top"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:background="@android:color/white">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Patient's gender:"
style="@style/bodyText"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/placeholder_text"
android:id="@+id/patientsGenderTextView"
android:gravity="right"
style="@style/blueBodyText"
/>
</LinearLayout>
<View style="@style/hr"
android:layout_margin="0dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="top"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:background="@android:color/white">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Patient's DOB:"
style="@style/bodyText"
android:id="@+id/patientsDOBTitle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/placeholder_text"
android:id="@+id/patientsDOBTextView"
android:gravity="right"
style="@style/blueBodyText"
/>
</LinearLayout>
<View style="@style/hr"
android:layout_margin="0dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="top"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:background="@android:color/white">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Patient's telephone:"
style="@style/bodyText"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:id="@+id/patientsTelephoneTextView"
android:gravity="right"
style="@style/blueBodyText"
android:text="@string/placeholder_text"/>
</LinearLayout>
<View style="@style/hr"
android:layout_margin="0dp"/>
<LinearLayout
style="@style/horizontalLinearLayout"
android:background="@android:color/white"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:gravity="top">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Patient's postcode:"
style="@style/bodyText"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:id="@+id/patientsPostcodeTextView"
android:gravity="right"
style="@style/blueBodyText"
android:text="@string/placeholder_text"/>
</LinearLayout>
<View style="@style/hr"
android:layout_margin="0dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="top"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:background="@android:color/white">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Patient's address:"
style="@style/bodyText"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:id="@+id/patientsAddressTextView"
android:gravity="right"
style="@style/blueBodyText"
android:text="@string/placeholder_text"/>
</LinearLayout>
<View style="@style/hr"
android:layout_margin="0dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="top"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:background="@android:color/white">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Reason for referral:"
style="@style/bodyText"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:id="@+id/referralReasonTextView"
android:gravity="right"
style="@style/blueBodyText"
android:text="@string/placeholder_text"/>
</LinearLayout>
<View style="@style/hr"
android:layout_margin="0dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="top"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:background="@android:color/white"
style="@style/verticalLinearLayout">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Patient presenting with:"
style="@style/bodyText"
android:layout_marginBottom="@dimen/very_small_vertical_spacing"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:id="@+id/additionalInfoTextView"
style="@style/blueBodyText"
android:text="@string/placeholder_text"
android:gravity="left"/>
</LinearLayout>
<View style="@style/hr"
android:layout_margin="0dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="top"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:background="@android:color/white">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Details of allergies:"
style="@style/bodyText"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:id="@+id/allergiesTextView"
android:gravity="right"
style="@style/blueBodyText"
android:text="@string/placeholder_text"/>
</LinearLayout>
<View style="@style/hr"
android:layout_margin="0dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="top"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:background="@android:color/white">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Registered surgery:"
style="@style/bodyText"
android:id="@+id/registeredTextTitle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:id="@+id/surgeryTextView"
android:gravity="right"
style="@style/blueBodyText"
android:text="@string/placeholder_text"/>
</LinearLayout>
<View style="@style/hr"
android:layout_margin="0dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="top"
android:paddingBottom="@dimen/small_vertical_spacing"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:background="@color/grey_light_expanded"
android:paddingTop="@dimen/small_vertical_spacing"
android:id="@+id/patientsBookingLocationHolder">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:id="@+id/patientsBookingLocationTextView"
android:gravity="left"
style="@style/boldBlueBodyText"
android:text="@string/placeholder_text"
/>
</LinearLayout>
<View style="@style/hr"
android:layout_margin="0dp"
android:id="@+id/patientsBookingLocationHolderHR"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="top"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:background="@color/grey_light_expanded">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Contact number:\n(at time of booking)"
style="@style/bodyText"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:id="@+id/contactNumberTextView"
android:gravity="right"
style="@style/blueBodyText"
android:text="@string/placeholder_text"/>
</LinearLayout>
<View style="@style/hr"
android:layout_margin="0dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="top"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:background="@color/grey_light_expanded"
android:id="@+id/patientRepHolder">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Patient's representative:"
style="@style/bodyText"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:id="@+id/representativeTextView"
android:gravity="right"
style="@style/blueBodyText"
android:text="@string/placeholder_text"/>
</LinearLayout>
<View style="@style/hr"
android:layout_margin="0dp"
android:id="@+id/patientRepHolderHR"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="top"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:id="@+id/ambulanceRequiredHolder"
android:background="@color/grey_light_expanded">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Ambulance required:"
style="@style/bodyText"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:id="@+id/ambulanceRequiredTextView"
android:gravity="right"
style="@style/boldBlueBodyText"
android:text="@string/placeholder_text"/>
</LinearLayout>
<View style="@style/hr"
android:id="@+id/ambulanceRequiredHolderHR"
android:layout_margin="0dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="top"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:id="@+id/patientsLocationHolder"
android:background="@color/grey_light_expanded">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Patient's location at time of booking:"
style="@style/bodyText"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Patient's name:"
android:id="@+id/patientsLocationTextView"
style="@style/blueBodyText"
android:layout_marginTop="@dimen/small_vertical_spacing"/>
</LinearLayout>
<View style="@style/hr"
android:id="@+id/patientsLocationHolderHR"
android:layout_margin="0dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="top"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:background="@android:color/white">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="I confirm that:"
style="@style/bodyText"
android:textStyle="bold"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text=""
android:layout_marginTop="@dimen/small_vertical_spacing"
android:gravity="left"
style="@style/bodyText"
android:textSize="12sp"
android:id="@+id/confirmationText"/>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
287 次 |
| 最近记录: |