我有一个使用片段的应用程序。 在我的一个用户的设备(HTC One)上,片段互相重叠,导致他的屏幕看起来很混乱:
我试图在自己的硬件上复制它,但不是HTC One。 我还尝试使用他所拥有的Android版本4.1.2,一切正常。 除了跑去买HTC One之外,有人有任何建议吗?
当我添加新片段时,我这样做
![enter image description here](https://istack.dev59.com/NwrkE.webp)
当我添加新片段时,我这样做
Fragment f = new MyFragment();
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
ft.replace(R.id.mainContent, f);
ft.addToBackStack(null);
ft.commit();
我的XML布局(仅保留相关部分):
<RelativeLayout>
<LinearLayout>
<!-- My home screen content is here -->
</LinearLayout>
<!-- This is where the fragment gets placed -->
<LinearLayout android:id="@+id/mainContent"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
</RelativeLayout>
更新
添加的片段具有以下布局:
<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"
android:background="@drawable/app_bg"
tools:context=".DeviceListActivity" >
<!-- snipped! (for brevity) -->
</RelativeLayout>
我一直在尝试 - 我发现如果我删除android:background,我可以复制这个问题,这让我相信HTC One由于某种原因导致片段的背景属性被忽略。