浮动操作按钮不适用于其他手机

时间:2016-01-11 17:22:39

标签: java android api floating-action-button

我已经构建了一个使用浮动操作按钮的应用程序。在我的应用程序上,我使用的是应用程序,FAB正常工作。在我的手机上我有Android 5.0.1。我已经将我的应用程序的APK发送到两个炒饼,一个有Android 4.2.2,另一个有4.1.2。在这款手机上,FAB无法正常工作。点击它时没有任何反应。

这是我的应用程序的清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tutecentral.mygames">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


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

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".OptionActivity"
        android:configChanges="orientation"
        android:screenOrientation="portrait">
    </activity>
    <!--
         ATTENTION: This was auto-generated to add Google Play services to your project for
         App Indexing.  See https://g.co/AppIndexing/AndroidStudio for more information.
    -->
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <activity android:name=".GameFocusActivity"
        android:configChanges="orientation"
        android:screenOrientation="portrait">
    </activity>
</application>

在19岁之前,FAB是否可能与API兼容?

更新

这是gradle文件:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.tutecentral.mygames"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),        'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'

}

1 个答案:

答案 0 :(得分:1)

<android.support.design.widget.FloatingActionButton
        android:id="@+id/nearby_fregment_card_user_showme"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="20dp"
        android:layout_marginRight="20dp"
        app:backgroundTint="@color/white"
        app:fabSize="normal" /

FloatingActionButton showMe;
showMe = (FloatingActionButton) v.findViewById(R.id.nearby_fregment_card_user_showme);
showMe.setOnClickListener(this);

public void onClick(View v)
    {
        if (v == showMe)
        {
            // event code
        }
   }

检查我的代码。我以这种方式使用它并在我的应用程序中正常工作

相关问题