2015-10-19 72 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修復的,現在它工作正常。 謝謝:) –