0

이 레이아웃을 만들 때이 코드를 사용합니다.왜이 레이아웃에 약간의 공간이 있습니까?

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_margin="20dp" 
       android:background="@android:color/transparent"> 
    <LinearLayout 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent" 
      android:orientation="vertical" 
      android:layout_centerInParent="true" 
      android:background="@drawable/rounded_white_bg"> 
     <EditText 
       android:id="@+id/login" 
       android:layout_height="wrap_content" 
       android:layout_width="match_parent" 
       android:background="@drawable/dialog_edittex" 
       android:layout_margin="10dp"/> 
     <EditText 
       android:id="@+id/password" 
       android:layout_height="wrap_content" 
       android:layout_width="match_parent" 
       android:layout_margin="10dp" 
       android:background="@drawable/dialog_edittex"/> 
     <TextView 
       android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:textColor="@android:color/black" 
       android:text="AAAAAAAAAAAA" 
       android:layout_gravity="center" 
       android:textSize="20sp" 
       /> 
     <ImageView 
       android:layout_height="wrap_content" 
       android:layout_width="match_parent" 
       android:src="@drawable/dialog_button_bg"/> 

    </LinearLayout> 


</RelativeLayout> 
rouded_whiite.bg.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <solid android:color="#ffffff" /> 
    <corners 
      android:radius="20dp"/> 
</shape> 

하지만이 작업을 수행 할 때이 결과를 볼 수 있습니다. 보시다시피 빨간 버튼 아래에 여백이 있습니다. 나는 여백을 설정하지 않았지만 거기에는 약간의 공간이 있습니다. 주먹 이미지에서와 같이 정확한 결과를 얻으려면 여기에서 어떻게해야합니까?

enter image description here

+1

android : layout_margin = "20dp"? –

+0

'LinearLayout'과'RelativeLayout'에'android : padding = "0dp"'를 설정하려고 했습니까? – Fllo

+2

왜 RelativeLayout을 사용하여 구현할 수 있는지 중첩 된 선형 레이아웃을 사용하고 있습니까? – r4jiv007

답변

1

사용 : 바닥에서

android:layout_centerHorizontal="true"

대신

android:layout_centerInParent="true"

제거 마진 ...

0
<LinearLayout 
     android:layout_height="wrap_content" 

이것 때문입니다. 선형 레이아웃에서 이미지 뷰를 제거하고 상대 레이아웃 설정 alignparent 바닥으로 재산을 포기하고 선형 레이아웃 alignparent의 상단과 이미지보기 속성 이상을주고,

1

당신의 RelativeLayout에서 마진을 제거하고 LinearLayout 중력을 android:layout_centerHorizontal="true"

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@android:color/transparent"> 
<LinearLayout 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:orientation="vertical" 
     android:layout_centerHorizontal="true" 
     android:background="@drawable/rounded_white_bg"> 
+0

그것은 형제가 작동하지 않았다. (아래 공간은 아직 남아 있습니다.) – pmb

+0

'dialog_edittex' 파일의 코드를 게시하십시오. – GrIsHu

0

보십시오이

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_marginTop="20dp" 
       android:background="@android:color/transparent"> 
    <LinearLayout 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent" 
      android:orientation="vertical" 
      android:background="@drawable/rounded_white_bg"> 
     <EditText 
       android:id="@+id/login" 
       android:layout_height="wrap_content" 
       android:layout_width="match_parent" 
       android:background="@drawable/dialog_edittex" 
       android:layout_margin="10dp"/> 
     <EditText 
       android:id="@+id/password" 
       android:layout_height="wrap_content" 
       android:layout_width="match_parent" 
       android:layout_margin="10dp" 
       android:background="@drawable/dialog_edittex"/> 
     <TextView 
       android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:textColor="@android:color/black" 
       android:text="AAAAAAAAAAAA" 
       android:layout_gravity="center" 
       android:textSize="20sp" 
       /> 
     <ImageView 
       android:layout_height="wrap_content" 
       android:layout_width="match_parent" 
       android:src="@drawable/dialog_button_bg"/> 

    </LinearLayout> 


</RelativeLayout> 
0

당신의 .PNG 또는 .j로 이미지 뷰에 대한 드로어 블을 사용하는 경우 Pg 이미지에 다음 drawable을 사용하면 도움이 될 수 있습니다. 당신은 그냥 무시하고 실행 경고를 다음 얻을 것이를 적용 할 때 당신이

<selector xmlns:android="http://schemas.android.com/apk/res/android" > 
<item > 
    <shape > 
     <corners android:bottomLeftRadius="20dp" 
      android:bottomRightRadius="20dp" 
      android:topLeftRadius="0dp" 
      android:topRightRadius="0dp"/> 
     <solid android:color="#CF4647"/> 
     <padding android:left="5dp" 
      android:top="5dp" 
      android:right="5dp" 
      android:bottom="5dp"/> 
    </shape> 
</item> 

원하는대로 backgroung_bg.xml 또는 다른 것으로이 저장합니다. 그라디언트 유형의 색상이 필요하면

레이아웃 편집기의 그래픽 미리보기가 정확하지 않을 수 있습니다. 다른 모서리 크기는 Path.addRoundRect에서 지원되지 않습니다. (이 세션에서는 무시)

관련 문제