2017-09-01 17 views
0

Ich möchte Welleneffekt auf meinem Symbol. Aber wenn ich Polsterung erhöhen reduziert es die Symbolgröße wenn Polsterung ist 5dp es so etwas wie dieses enter image description herePadding reduziert Icon-Größe in ImageView

sieht aber wenn ich padding Größe erhöhen, um 12dp es wie diese xml enter image description here

Mein Image sieht

<ImageView 
      android:id="@+id/institute_search_item_request_icon" 
      android:layout_width="40dp" 
      android:layout_height="40dp" 
      android:layout_alignParentEnd="true" 
      android:layout_marginEnd="20dp" 
      android:layout_marginTop="15dp" 
      android:background="@drawable/request_institute_red_icon__shape" 
      android:foreground="@drawable/ripple_foreground" 
      android:padding="12dp" 
      android:src="@drawable/ic_link_white_24dp" /> 

request_institute_red_icon__shape.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="oval"> 

<solid android:color="@color/colorPrimary" /> 

und

<ripple xmlns:android="http://schemas.android.com/apk/res/android" 
android:color="@color/colorAccent"> 
<item android:id="@android:id/mask"> 
    <shape android:shape="oval"> 
     <solid android:color="@color/colorPrimary" /> 
    </shape> 
</item> 

+0

Warum brauchen Sie Polsterung? –

+0

verwenden Marge das tun. –

+0

@ Bhuvanesh ich will Ripple Farbe um Symbol. Bitte korrigieren Sie mich, wenn ich einen dummen Fehler mache – FaisalAhmed

Antwort

0

Entfernen Polsterung ripple_foreground.xml, es wird Ihr Symbol schrumpfen. In Sie imageview nur diese Zeile hinzufügen Ripple-Effekt zu erhalten

android:foreground="?attr/selectableItemBackground" 

Um oval Welligkeit:

round_background.xml

<ripple xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:color="@color/colorAccent" 
    android:radius="your_radius" // try radius 
    tools:targetApi="lollipop"> 
    <item android:id="@android:id/mask"> 
     <shape android:shape="oval"> 
      <solid android:color="@color/colorPrimary" /> 
     </shape> 
    </item> 
    <item android:drawable="@drawable/red_background" /> 
</ripple> 

red_background.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <solid android:color="@color/red_color"/>/> 
</shape> 
+0

Ich habe es schon ausprobiert. Es gibt mir keinen ovalen Welleneffekt. Es erscheint in Ractangle-Form mit dieser Lösung – FaisalAhmed

+0

Versuchen Sie meine aktualisierte Antwort –

+0

immer noch zeigt es Rechteck Kräuseleffekt – FaisalAhmed