Issue
I want to just have a button where the image will be the background, instead of loading the button to be the images. For example, no matter what size the image is, I still want the button to stay the same size. I tried to edit my image to be the same size, but the nice rounded corners are now gone and I don't have the software to put corners on an image accurately.
Do I just have a different understanding of what background means? I would think that It would draw the button and then put the image as the background instead of draw the button, then re-draw the button to be the same size as the background image.
Below is the xml code for my button:
<Button
android:id="@+id/newUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:background="@drawable/ButtonSize"
android:elevation="0dp"
android:text="New User"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/spinner"
tools:textColor="@android:color/black" />
The line in question is the android:background="@drawable/ButtonSize"
and my file ButtonSize.png is a 90x50 pixel image that would fit really nicely onto an Button.
My question is: Is there any other way to set the image purely as a background in a literal sense, where I could also, for example, add curved edges using android:bottomLeftRadius="30dp"
, ect.
Solution
Instead of using Button you can use Image button and set the following property will give the image to Entire Button.
android:scaleType="centerInside"
android:adjustViewBounds=true
For more reference visit the following linkAndroid ImageButton Resolution Problems
Hope It will help you
Answered By - Suresh
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.