1

我試圖在開關compat上應用激進的反應/紋波效應,但是我能從中得到最多的效果是短暫的。我在一排中有一個開關,一旦開關打開和關閉,我想在整個行中突出顯示。目前唯一突出的是轉換器,不會產生連鎖反應,就像轉換器本身的一個沉悶的高光。一旦開關翻轉,是否有可能在整個行中發出波紋/波紋效應? 這裏是我的代碼:switchcompat可能會產生連鎖反應嗎?

<FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/altercolor2" 
     android:padding="@dimen/common_padding"> 

     <com.myapp.utils.FontTextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:textColor="#ffffff" 
      android:paddingTop="@dimen/common_top_padding" 
      android:paddingLeft="0dp" 
      android:paddingBottom="@dimen/common_bottom_padding" 
      android:textSize="@dimen/title" 
      foo:customFont="proxima-nova-regular.ttf" 
      android:text="@string/display_image" /> 

     <android.support.v7.widget.SwitchCompat 
      android:id="@+id/display_image_toggle_control" 
      foo:theme="@style/MyMaterialTheme.Switch" 
      android:background="?attr/selectableItemBackgroundBorderless" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="right|center_vertical" 
      android:layout_marginLeft="@dimen/toggle_margin_leftright" 
      android:layout_marginRight="2dp" /> 
    </FrameLayout> 

回答

0

您可以添加自己的連鎖效應,營造drawable-v21文件夾,並把下面繪製作爲背景的FrameLayout我想解決您的問題:

<?xml version="1.0" encoding="utf-8"?> 

<ripple xmlns:android="http://schemas.android.com/apk/res/android" 
    android:color="@color/gray_light"> 
    <item 
     android:id="@android:id/mask" 
     android:drawable="@color/gray" /> 
</ripple> 

另外補充:

android:clickable="true" 
android:focusable="true" 

是否有可能在整個送出一波/漣漪效應一旦交換機翻轉,整個 行?

我認爲你需要在你的Views中設置​​和background

+0

上述framelayout包含在,我在前景和背景中添加什麼,還有我在哪裏添加focusable在交換機中還是在包含它的framelayout中? –

+0

添加焦點和可點擊的根源。 – Amir

+0

我該如何增加漣漪效應的直徑,目前它似乎在半途而廢? –