按钮显示在下一个屏幕上

时间:2015-08-13 05:41:37

标签: android android-layout android-fragments android-button

我在一个片段上有一个按钮设计如下:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:tag="ActivityFragment"
    android:id="@+id/fragment_activity_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
...
...

<Button
        android:id="@+id/btnCreateActivity"
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:layout_gravity="right|top"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:background="@drawable/create"
        />
</FrameLayout>  

OnClick这个按钮,我正在转向另一个片段:

btnCreateActivity.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    FragmentManager fm = getActivity().getSupportFragmentManager();
                    FragmentTransaction transaction = fm.beginTransaction();
                    transaction.addToBackStack(null);
                    transaction.setCustomAnimations(R.anim.enter_anim, R.anim.exit_anim, R.anim.enter_anim, R.anim.exit_anim);
                    WebFragment fragment = WebFragment.newInstance(Globals.TGURL_CREATE_ACTIVITY, "");
                    transaction.replace(R.id.fragment_activity_layout, fragment);
                    transaction.commit();
                }
            });  

WebFragment (下一个屏幕)加载时, btnCreateActivity 仍然存在。

fragment_web布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent"
    android:id="@+id/webFragment"
    android:layout_height="fill_parent"
    tools:context="truegroups.activities.WebFragment"
    android:background="#ffffff">
        <WebView
            android:id="@+id/webFragment_webview"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            />
</RelativeLayout> 
  

这仅适用于Galaxy Note 3,Galaxy S3等少数设备。

在其他设备上,它可以正常工作,并且按钮不会显示在下一个屏幕上 为什么这样?

2 个答案:

答案 0 :(得分:0)

您调用的新片段位于堆栈顶部。由于它具有透明/空背景,因此较低片段上的控件仍然可见。

答案 1 :(得分:0)

将您的按钮放在framelayout旁边

相关问题