android - how to set image in proper position in layers in layer-list? -


i trying set image in center of circle (trying on android 4.1.2)

enter image description here

but when run app shows image this

enter image description here

but when writing code in xml shows right image enter image description here

here xml code

<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">      <item android:right="-1dp"         android:left="-1dp"         android:bottom="-1dp">          <shape>             <solid android:color="#50000000" />             <corners android:radius="50dp" />         </shape>      </item>      <item android:height="20dp" android:width="20dp">          <shape>             <corners android:radius="50dp" />             <stroke android:color="@color/white"                 android:width="1dp"/>             <solid android:color="#50000000"/>          </shape>      </item>      <item  android:width="8dp"         android:height="8dp"         android:gravity="center"         android:drawable="@drawable/news">      </item>  </layer-list> 

you can try this,

<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">      <item>          <shape android:shape="oval">             <solid android:color="#50000000"/>         </shape>      </item>      <item>          <shape android:shape="oval">             <stroke                 android:width="1dp"                 android:color="@color/coloraccent"/>             <solid android:color="#50000000"/>          </shape>      </item>      <item         android:bottom="5dp"         android:drawable="@drawable/news"         android:gravity="center"         android:left="5dp"         android:right="5dp"         android:top="5dp">     </item>  </layer-list> 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -