谁能介绍下SwipeBackLayout用法,弄了1天失败

时间:2023-01-30 23:50:39
想实现常用布局效果,现在用的bottomnavigationbarviewPager+fragment   单独一个Fragment + TabLayout +viewpager测了了可以用,还想加个功能swipebacklayout,就是点击按钮有个界面从右边动画覆盖主界面,滑动回退或者回退键回退效果
单独开个测试项目 , 想实现的功能是主activity就是正常activity,  Swipe可以实现从右侧动画进入动画退出,运行程序直接stop
1-12 22:06:27.214 2639-2639/com.bin.swipe E/AndroidRuntime: FATAL EXCEPTION: main
                                                             Process: com.bin.swipe, PID: 2639
                                                             java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bin.swipe/com.bin.swipe.Swipe}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class me.imid.swipebacklayout.lib.SwipeBackLayout
                                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
                                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
                                                                 at android.app.ActivityThread.-wrap11(Unknown Source:0)
                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
                                                                 at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                 at android.os.Looper.loop(Looper.java:164)


build.gradle 
implementation 'me.imid.swipebacklayout.lib:library:1.0.0'
implementation 'com.android.support:support-v4:26.1.0'

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Intent intent = new Intent(this, Swipe.class);
        startActivity(intent);
    }
}

public class Swipe extends SwipeBackActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_swipe);

    }
}

<me.imid.swipebacklayout.lib.SwipeBackLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <LinearLayout android:layout_width="match_parent"
        android:layout_height="match_parent">

    </LinearLayout>

</me.imid.swipebacklayout.lib.SwipeBackLayout>

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>
    <style name="SwipeTheme">
        <item name="android:windowIsTranslucent">true</item>
    </style>
</resources>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.bin.swipe">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".Swipe"
            android:theme="@style/SwipeTheme"></activity>
    </application>

</manifest>

1 个解决方案

#1


解决了,主activitycontainerlayout问题,改成linearlayout就好了,我

#1


解决了,主activitycontainerlayout问题,改成linearlayout就好了,我