android textView-文本和顶部textView边框之间的间隙
我想创建一个文本视图,该文本将填充所有高度 这是我的代码:android textView-文本和顶部textView边框之间的间隙,android,Android,我想创建一个文本视图,该文本将填充所有高度 这是我的代码: TextView android:id="@+id/year" android:layout_width="wrap_content" android:layout_height="40dp" android:gravity="center_vertical|center_horizontal" android:textColor="#ffffff" android:textSize="4
TextView
android:id="@+id/year"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:gravity="center_vertical|center_horizontal"
android:textColor="#ffffff"
android:textSize="40dp"
android:background="#0080f0"
android:text="2014"/>
问题是文本和顶部文本视图边框之间存在间隙
textview是caendar的一部分
这是屏幕需要的外观:
谢谢 尝试删除字体填充。将以下内容添加到xml文本视图:
android:includeFontPadding="false"
尝试将
layout\u height
设置为wrap\u content
尝试使用paddingTop设置layout\u height可在顶部和底部创建间隙使用paddingTop增加顶部间隙。我正在试图消除这种差距。像这样做吧,android:paddingTop=-你的号码@ZagGol这就尽可能地消除了字体填充。你能发布一些图片来说明你想要什么吗?@ZagGol如果你绝对需要删除文本上方(和/或下方)的空间,你应该扩展视图并自己绘制文本。您要覆盖的方法是onDraw(Canvas)
。这样做将允许您根据需要定位文本。