I wanted to put the icon on top of the materialButton like shown here:
But I couldn't find any properties in MaterialButton to set the gravity of the app:icon to top. I could only able to set it to start or end. Is there any way to set the create a similar button without using Vertical LinearLayout with ImageView and TextView?
You can use android:drawableTop
attribute for this
Note: This is not only restricted for the MaterialButton you can use it on TextViews and other views also
Example Code:
<com.google.android.material.button.MaterialButton
android:layout_width="match_parent"
android:text="@string/app_name" <!-- Your Text -->
android:drawableTop="@drawable/ic_launcher_background" <!-- Your Icon -->
android:layout_height="wrap_content"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.