2012-07-10 12 views
6

Wygląda na to, że niektóre widoki, takie jak TextView, mają własne dopełnienie lub margines ... Mam na myśli, że gdy ustawiam textSize 16dp na textView, to na ekranie urządzenia hdpi potrzeba więcej niż 24 pikseli, aby wyświetlić tę kontrolkę . Może ja czegoś brakuje, prosimy o pomocWidok android domyślne wypełnienie lub marginesy

<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

Czy spodziewasz się, że będzie dokładnie 24 oparte na mnożniku 1,5x stąd: http://developer.android.com/guide/practices/screens_support.html? –

+0

No tak ... Przypuszczam, że jeśli chcę uzyskać rozmiar tekstu 24px na urządzeniu hdpi, muszę ustawić textSize na 16dp czy nie? – Orest

+0

Tak, masz rację, tylko próbujesz zrozumieć związek. Czy mówisz, że rzeczywisty tekst jest większy niż 24 piksele lub tekst + przestrzeń wokół niego? –

Odpowiedz

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> 

w Android podczas korzystania z układów, marginesy standardowe i wyściółka dostępny jest taka: @ Dimen/activity_vertical_margin lub @ Dimen/activity_horizontal_margin. Podałem przykładowy kod powyżej.