开发者

How can I reduce the margin?

One of my views looks like this right now. Near the big 5, specifically above and开发者_如何学Python below it, there is considerable margin. How can I reduce or remove this margin?

How can I reduce the margin?

The related XML code looks like this:

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
    <TextView style="@style/medText" android:id="@+id/whenSee" android:text="@string/whenSee" android:layout_alignParentLeft="true" android:layout_above="@+id/newViewValue" android:gravity="center" android:layout_alignRight="@+id/button_to_press"></TextView>
    <TextView style="@style/numberSelect" android:id="@+id/newViewValue" android:text="9" android:layout_above="@+id/press_text" android:layout_alignParentLeft="true"  android:gravity="center" android:layout_alignRight="@+id/button_to_press"></TextView>
    <TextView style="@style/medText" android:id="@+id/press_text" android:layout_above="@+id/button_to_press" android:layout_alignParentLeft="true" android:text="@string/press"  android:gravity="center" android:layout_alignRight="@+id/button_to_press"></TextView>
</RelativeLayout>

Styles are here:

<style name="medText">
    <item name="android:textSize">22sp</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_width">wrap_content</item>
</style>
<style name="numberSelect">
    <item name="android:textSize">80sp</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_width">wrap_content</item>
</style>


Add attribute android:includeFontPadding="false" to big TextView, it must shrinks paddings.


I had a similar problem - two lines one above the other - were two far away. It is because of space left in texts so that accented characters would not stick to symbols like 'y' from lines above. The solution is to use negative margin: -5px, -5dp. Just se it on the TextView with 5, because that's where the most blank comes from. On one side you're safe since there are only numbers. On the other hand you can never know what font is used. You can probably use images, too.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜