2015-10-19 66 views
2

我添加使用姜饼设备也不断显示没有背景颜色的按键测试浮动的操作按钮,以我的应用程序与图像inside.png安卓:浮动操作按钮与透明背景

出现。但棒棒糖其确定

这里是我的活动代码

import android.os.Bundle; 
import android.support.v7.app.AppCompatActivity; 
import android.support.v7.widget.Toolbar; 

import butterknife.Bind; 
import butterknife.ButterKnife; 

public class MainActivity2 extends AppCompatActivity { 
    @Bind(R.id.toolbar)Toolbar toolbar; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main2); 
     ButterKnife.bind(this); 
     setSupportActionBar(toolbar); 

    } 
} 

,这里是我的xml文件

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:card_view="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

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

    <include 
     layout="@layout/toolbar" /> 

    <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/card" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="@dimen/dp10" 
     android:background="@color/card" 
     android:gravity="center" 
     card_view:cardCornerRadius="5dp"> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" 
      android:padding="@dimen/dp5"> 

      <EditText 
       android:id="@+id/main_edt_from" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="@dimen/dp30" 
       android:hint="@string/amount" 
       android:inputType="numberDecimal" /> 
     </LinearLayout> 

    </android.support.v7.widget.CardView> 
</LinearLayout> 

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/btn_next" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_margin="@dimen/dp15" 
    android:src="@drawable/ic_send" 
    app:elevation="2dp" 
    app:fabSize="normal" 
    app:layout_anchor="@id/card" 
    app:layout_anchorGravity="bottom|right|end" /> 

我的摇篮是

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.1" 

    defaultConfig { 
     applicationId "com.kr.currencyconverter" 
     minSdkVersion 10 
     targetSdkVersion 23 
     versionCode 4 
     versionName "2.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.jakewharton:butterknife:7.0.1' 
    compile 'com.android.support:appcompat-v7:23.0.1' 
    compile 'com.android.support:support-v4:23.0.1' 
    compile 'com.android.support:design:23.0.1' 
    compile 'com.google.android.gms:play-services:8.1.0' 
    compile 'com.android.support:cardview-v7:23.0.1' 
    } 

我已经尝试过了将app:backgroundTint="@color/accent"添加到浮动操作按钮,但它不起作用。

这里是要表明我的意思的图像。在测试中,我得到一个透明的按钮 enter image description here

+0

请尝试在XML中为浮动操作按钮提供一些背景颜色以避免透明。 – dex

+0

@dex我已添加应用程序:backgroundTint =“@ color/accent”但它没有工作 –

+0

给予android:alpha =“1.0f”用于晶圆厂和检查 –

回答

0

必须设置

app:backgroundTint="@color/yourcolor" 
+0

不,它没有工作 –

+0

我觉得'色调'不能适用于小于'棒棒糖' –

0

在此附上该图标

"@dimen/dp15" 

有似乎是这张图片中的背景色。

+0

的版本你能发表吗?我已经这样做了android:layout_margin =“@dimen/dp15” android:src =“@ drawable/ic_send” –

+0

我的意思是,图像android:src =“@ drawable/ic_send”,检查它是否有背景色。 –

+0

你可以尝试设置ic_send作为按钮背景 –

0

我有一个与FloatingActionButton(FAB)类似的问题。在我的例子中,我在Activity中使用了片段,并且在我的活动的布局文件中有FAB。所以片段呈现在FAB之上。所以我不得不在onPostResume()方法中添加fab.bringToFront();以使其工作。

@Override 
protected void onPostResume() { 
    super.onPostResume(); 
    fab.bringToFront(); // fab - reference of FloatingActionButton 
} 

此外,检查布局的高程应小于FAB的高程。

+0

这是一个支持库23.0.1的bug,它是从Google修复的,现在它工作正常。 谢谢:) –