Android, remove margin and padding from element

前端 未结 4 1671
独厮守ぢ
独厮守ぢ 2021-01-22 12:38

i\'ve an activity that contains a LinearLayout (horizontal), i want that all elements inside the LinearLyout are attached, without margin or padding. I\'ve tried many methods bu

相关标签:
4条回答
  • 2021-01-22 13:13

    Always use RelativeLayouts. Not use Linear inside relative. The best practices in android:

    http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html

    Use for example commands like:

    layout_above
    layout_toRightOf
    layout_alignParentTop
    etc.
    
    0 讨论(0)
  • 2021-01-22 13:13

    In values/dimens.xml file you can set margins.

    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="activity_horizontal_margin">0dp</dimen>
    <dimen name="activity_vertical_margin">0dp</dimen>
    

    0 讨论(0)
  • 2021-01-22 13:22

    You can use android:layout_weight property in LinearLayout,this will override all th padding,

        <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:weightSum="3">
    
     <TextView
        .
        .
        .
        android:layout_weight="1" />
    
    <TextView
        .
        .
        .
        android:layout_weight="1" />
    
    <TextView
        .
        .
        .
        android:layout_weight="1" />
     </LinearLayout>
    
    0 讨论(0)
  • 2021-01-22 13:23

    Look in your RelativeLayout parent container and instead of:

    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    

    put dimension to 0dp:

    android:paddingRight="0dp"
    android:paddingTop="0dp"
    android:paddingBottom="0dp"
    
    0 讨论(0)
提交回复
热议问题