2012-07-10 33 views
6

似乎像TextView的一些意见有其自己的填充或边距...我的意思是,当我设置textSize 16dp textView,它需要多个24像素在hdpi设备屏幕上显示此控件。也许我失去了一些东西,请在使用的布局有助于安卓视图默认填充或边距

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

     <View 
      android:layout_width="match_parent" 
      android:layout_height="1px" 
      android:background="@color/closed_red" /> 

     <TextView 
      android:id="@+id/uc_button_title_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_margin="0dp" 
      android:includeFontPadding="false" 
      android:background="@null" 
      android:padding="0dp" 
      android:text="@string/demo_text" 
      android:textColor="#325083" 
      android:textSize="16dp" 
      android:textStyle="bold" /> 

     <View 
      android:layout_width="match_parent" 
      android:layout_height="1px" 
      android:background="@color/closed_red" /> 
    </LinearLayout> 
+0

您是否期待它完全基于来自此处的1.5倍乘数:24:http://developer.android.com/guide/practices/screens_support.html? – 2012-07-10 20:07:03

+0

好吧..我想如果我想在hdpi设备上获得24px的文本大小,我必须将textSize设置为16dp或不? – Orest 2012-07-10 20:16:54

+0

是的你是对的,只是试图理解这种关系。那么你是说实际文字大于24px还是文字+它周围的空格? – 2012-07-10 20:19:29

回答

4
<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="@dimen/activity_vertical_margin" 
     android:layout_marginBottom="@dimen/activity_vertical_margin" 
     android:layout_marginLeft="@dimen/activity_horizontal_margin" 
     android:layout_marginRight="@dimen/activity_horizontal_margin" 
     android:orientation="vertical"> 
    </LinearLayout> 

在Android中,默认边距和可用的填充是这样的:@扪/ activity_vertical_margin或@扪/ activity_horizo​​ntal_margin。我已经在上面提供了一个示例代码。