使用SwipeBackLayout时如何保持活动布局

时间:2014-10-04 10:32:58

标签: android

最近,我在github上使用SwipeBackLayout https://github.com/Issacw0ng/SwipeBackLayout

我有两个活动:A和B,B扩展SwipeBackActivity,A开始活动B.还设置B的主题:<item name="android:windowIsTranslucent">true</item>

当滑动B的左边缘时,它应该返回A并且当B滑动时背景应该是A.但是B滑动时的背景是我手机的桌面?谁能解释一下呢?

这是B活动 - BackActivity

public class BackActivity extends SwipeBackActivity {

    private SwipeBackLayout swipeBackLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_back);
        swipeBackLayout = getSwipeBackLayout();
        swipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_LEFT);
    }
}

A活动 - MainAcitity

public class MainActivity extends SwipeBackActivity {

    private SwipeBackLayout swipeBackLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        swipeBackLayout = getSwipeBackLayout();
        swipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_LEFT);

    }

    public void GoClick(View view){
        Intent intent = new Intent(this, BackActivity.class);
        startActivity(intent);
    }
}

1 个答案:

答案 0 :(得分:0)

获取新版本,添加到您的project.Notice style.xml与<item name="android:windowIsTranslucent">true</item>,只需这样做,很容易