简体   繁体   中英

Android :Button drawable Top

I want to create metro UI, so I did like in the picture But the problem is the position of the icons, they are in the top of the button, and I don't think it's aesthetic interface. I inserted the icons in the drawable Top in the button. Well how can make the a little bit in the middle.

在此处输入图片说明

You have to set the android:paddingTop and android:paddingBottom eqaully. Just don't copy and paste 10dp as the value of the padding. Value depends on the size of your button. Refer to below:

             <Button
                android:id="@+id/find_teacher"
                style="@style/page_button"
                android:drawableTop="@drawable/ic_search_light"
                android:text="@string/find_teacher" 
                android:paddingTop="10dp"
                android:paddingBottom="10dp"/>

This is the output:

在此处输入图片说明

I can remember 2 options:

  • top padding
  • gravity

You might wan't to check the layout documentation

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM