How to adjust image for custom imagebutton?

一世执手 提交于 2020-01-07 02:47:17

问题


I created custom triangle button, from code which was given by wonderful user so, here : How to create layout with buttons like on this picture? ( BUTTON THAT HAVE ACTUALLY SHAPE OF TRIANGLE, NOT MASK )

And i came in level, for adjusting design. I tried to make 9-patch img, also with normal, but it looks for inner button like this:

And then bump into finding way for adjusting that image into triangle custom button, and found this solution: Android - Image Button Scale

But what i got is not good for me. Here what i tried :

  <FrameLayout
       android:layout_width="270dp"
       android:layout_height="270dp"
       android:layout_centerHorizontal="true"
       android:layout_centerVertical="true"
       android:background="@drawable/custom_border" >

       <custom_button.TriangleButton
           android:id="@+id/btn_bottom"
           android:layout_width="250dp"
           android:layout_height="200dp"
            android:text="Second Button"
            android:textColor="#000"
            android:layout_gravity="center_horizontal"
            android:gravity="bottom|center_horizontal"
            android:padding="13dp"/>



       <custom_button.TriangleButton
            android:id="@+id/btn_top"
            android:layout_width="130dp"
            android:layout_height="110dp"
            android:text="First Button"
            android:textColor="#000"
            android:layout_gravity="center_horizontal"
            android:gravity="bottom|center_horizontal"
            android:layout_margin="55dp"
            android:padding="30dp"
            android:onClick="callAdditionActivityButton"
            android:src="@drawable/triangle"
            android:adjustViewBounds="true"
            android:scaleType="fitXY"/>



   </FrameLayout>

I have on mind to create triangle (with my art) in rectangle (normal image) to fit center of rectangle, in way, down_left_corner, center_top, down_right_corner, respectivly created in code. And around triangle make transparent. How to achieve this? Main issue how to adjust picture, second is transparent background...

EDIT: My image's size is: 502 x 302, bit depth 32

MY desired picture for adjusting, i want this circle to be in center in custom button :

来源:https://stackoverflow.com/questions/35612825/how-to-adjust-image-for-custom-imagebutton

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!