Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android view default padding or margins

Tags:

android

view

It seems some views like TextView has its own padding or margin...I mean when I'm setting textSize 16dp to textView, it takes more then 24 pixels on hdpi device screen to display this control. Maybe I'm missing something, please help

<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>
like image 903
Orest Avatar asked Jul 10 '12 20:07

Orest


1 Answers

  <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>

In android while using layouts, the default margins and padding available is this: @dimen/activity_vertical_margin or @dimen/activity_horizontal_margin. I have put an example code above.

like image 94
Anand S Joshi Avatar answered Oct 13 '22 11:10

Anand S Joshi