2017-11-08 1 views
-1

LinearLayout을 (부모 레이아웃과 같이) 화면 가장자리에서 시작하려고합니다. 두 레이아웃 사이의 공백을 원하지 않습니다. 화면 가장자리에서부터 왼쪽에서부터 시작해야합니다. 부모 left 및 top 속성을 따릅니다.자녀 배치 설정 방법 또한 부모 위치에서 시작 하시겠습니까?

참고 : 선형 레이아웃 속성의 변경 사항 만 수정하는 방법을 의미한다고 생각하십니까?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="com.example.zd.MainActivity" > 


<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:id="@+id/preview" 
     android:focusable="true"> 
     <requestFocus /> 

    </LinearLayout> 
</RelativeLayout> 
+0

나는 당신이 무엇을 덧붙이고 있는지, 왜 우리가 사용하는지 알고 있다고 생각합니다. –

+0

이제 질문을 업데이트 – Moorthy

답변

0

이 줄을 제거하십시오. 이것은 자녀를위한 패딩입니다.

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

하지만 질문에 따라.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/gray" 

    android:clipToPadding="false" // this will do the trick here 

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

    // suppose you have 16dp padding 
    <LinearLayout 
     android:layout_marginTop="-16dp" 
     android:layout_marginBottom="-16dp" 
     android:layout_marginLeft="-16dp" 
     android:layout_marginRight="-16dp" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="horizontal" 
     android:id="@+id/preview" 
     android:background="@color/green" 
     android:focusable="true"> 
     <requestFocus /> 

    </LinearLayout> 
</RelativeLayout> 
+0

Relatievlayout 속성을 변경하고 싶지 않다고 가정합니다. 선형 레이아웃의 변경 사항은 수정 방법을 의미합니까? – Moorthy

+0

위에서 사용하고있는 패딩 ... LinearLayout에서 음수 부호가있는 동일한 패딩을 사용합니다 ... 시도하지 않았습니다 .. 시도해 볼 수 있습니다. –

+0

좋습니다. @SRB – Moorthy

0

DO LIKE BELOW.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.zd.MainActivity" > 


<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:id="@+id/preview" 
     android:focusable="true"> 
     <requestFocus /> 

    </LinearLayout> 
</RelativeLayout> 
+0

Relatievlayout 속성을 변경하고 싶지 않다고 가정하면 linearlayout의 변경 사항은이를 수정하는 방법을 의미합니까? – Moorthy

+0

그 다음 불가능합니다. –

+0

그게 형제 야. . – Moorthy

관련 문제