开发者

Android - button height does not change

I am unable to make the height of my button smaller. Here's what I have in my xml:

<Button xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/button_small_left"
        style="?android:attr/buttonStyleSmall"
        android:layout_height="10px"
        android:height="10px"
        android:minHeight="10px"
        android:maxHeight="10px"
        android:pad开发者_C百科ding="0px"
        android:textSize="6dip"
        android:text="asd"
/>

The button still shows up with a big top and bottom padding after this. The text appears in the middle. The button is used inside a relative layout.


Instead px (pixel) use dp(density pixel) for buttons height and width.

Ex:

android:layout_height="10dp"

and for text size use only sp(scale index pixel)

android:textSize="6sp"

In your above xml you forget to give width attribute.

android:layout_width="40dp"


Strange - this does work fine when I created a new project to try again. The problem should have been somewhere else.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜