开发者

How to get rid of extra spacing in LinearLayout?

开发者 https://www.devze.com 2023-01-19 08:34 出处:网络
I\'ve built a widget that uses a LinearLayout and I\'ve put two TextViews in the layout. The gravity of the layout is \"top\".

I've built a widget that uses a LinearLayout and I've put two TextViews in the layout. The gravity of the layout is "top".

The problem is that I get a space between the two TextViews and I can't get rid of it.

    <TextView 
        android:id="@+id/Text01"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:gravity="bottom|center_horizontal" 
        android:text="blah blah"
        android:background="@android:color/transparent"
        android:textColor="#3e6eb4"
        android:textSize="11sp"
        />        

    <TextView 
        android:id="@+id/text02"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:gravity="top|center_horizontal" 
        android:text=""
        android:background="@android:color/transparent"
        android:textColor="#3e6eb4"
        android:textSize="14sp"
        android:padding="0sp"
        android:verticalSpacing="0sp"
        />

As you can see I tried putting padding 0 and verticalSpacing 0 but I still get a space between the开发者_运维知识库m.

How can I fix it?

Thanks.


You can also try using a negative margin (just like CSS :)

(I did it with my App and it works great)

<TextView
android:layout_marginTop="-10dp"
android:layout_marginBottom="0dp"
/>

Hope this helps!


Try setting the following properties :

<TextView
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
/>


You're using sp instead of dp for some of you attributes. Only use sp for font sizes. :)

0

精彩评论

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

关注公众号