2015-03-02 217 views
0

在布局化妆过程中,我经常需要像素与像素等效的模板。而使用TextView,我遇到了麻烦。它有奇怪的垂直尺寸 - 它等于字体大小和一些填充以上和以上 - 从1到4 DP,我想。它与不同的字体大小和风格不同,甚至更糟,不可预知的不同。有什么办法可以禁用这种填充吗? padding in textViewTextView高度依赖字体大小与wrap_content参数

代码示例:

<LinearLayout 
       android:id="@+id/llCardData" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" > 

       <!-- android:background="@drawable/red_frame_animation" --> 

       <TextView 
        android:id="@+id/tvCardNameLabel" 
        style="@style/LabelDefaultText" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/ncn_name" /> 

       <TextView 
        android:id="@+id/tvCardCustomName" 
        android:layout_marginTop="3dp" 
        style="@style/PropertyDefaultText" 
        android:layout_width="match_parent" 
        android:layout_height="50dp" 
        android:background="@color/panel_background" 
        android:gravity="left|center_vertical" 
        android:paddingLeft="8dp" /> 
      </LinearLayout> 

上的TextView有字体大小16 DP,但占地约20-22dp

+0

您线性布局或有什么用?给一些例子 – Martynas 2015-03-02 14:20:01

+0

添加代码示例。 – Raiv 2015-03-02 15:12:07

+0

作为一种修复方式,我可以为TextView添加固定高度,就像我在第二个TextView中做的那样。但是,如果风格发生变化,那将很难正确地更改所有视图。 – Raiv 2015-03-02 15:15:09

回答

2

尝试android:includeFontPadding="false"在TextViews

+0

删除字体填充,但我想它的大小 – Raiv 2015-06-03 18:22:56