마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

위와 아래의 길이를 맞추고 싶은데.. 어떻게 해야할지 모르겠어요.

0 추천

 

 

안녕하세요 ..

위의 레이아웃과 아래의 레이아웃의 길이를 맞추고 싶은데.. 너무 힘듭니다 ㅠ

내부에 padding을 줘서 최대한 두번째 줄에 각 에디트 텍스트의 패딩을 줘서

줄이려고 하는데도 쉽게 되질 않네요..

바로 아래의 사진을 보면, 위의 이름을 입력하는 곳과, 생일의 길이를 좀 맞추고싶어요.

아래의 사진에서 어떻게 해야, 이름을 입력하는 부분과 너비가 같은 길이에 생년월일을 다

집어넣을수 있을까요.. 아래에 제가 만든 소스를 한번 올려보겠습니다 ㅠ

소스가 별로 길지 않은데.. 8000자 제한 떄문에, 아래의 댓글에 이어서 좀 붙여보겠습니다.

 

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp">

    <TextView
        android:id="@+id/Text_register_Name"
        android:layout_width="80dp"
        android:layout_height="wrap_content"

        android:layout_centerVertical="true"

        android:layout_marginLeft="15dp"

        android:textStyle="bold"
        android:textColor="#000000"
        android:textSize="13sp"
        android:text="이름"/>

    <EditText
        android:id="@+id/Edit_Register_Name"
        android:maxLines="1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:layout_toRightOf="@+id/Text_register_Name"

        android:layout_marginRight="45dp"

        android:paddingTop="10dp"
        android:paddingBottom="10dp"

        android:background="@drawable/white_round_button"
        android:textAlignment="center"
        android:hint="홍 길 동"/>


</RelativeLayout>
 
 

공산당 (1,960 포인트) 님이 2016년 10월 31일 질문
공산당님이 2016년 10월 31일 수정
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_marginTop="10dp">

    <TextView
        android:id="@+id/Text_register_Birth_Year"
        android:layout_width="80dp"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="15dp"
        android:textStyle="bold"
        android:textColor="#000000"
        android:textSize="13sp"
        android:text="생년월일"/>


    <EditText
        android:id="@+id/Edit_Register_Birth_Year"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="1973"
        android:layout_weight="1"
        android:inputType="number"
        android:maxLines="1"
        android:maxLength="4"
        android:textAlignment="center"
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        android:layout_marginRight="2dp"


        android:background="@drawable/white_round_button"
        />


    <EditText
        android:id="@+id/Edit_Register_Birth_Month"

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="09"
        android:inputType="number"
        android:maxLines="1"
        android:maxLength="2"
        android:layout_weight="1"
        android:textAlignment="center"
        android:paddingTop="10dp"
        android:layout_marginRight="2dp"
        android:layout_marginLeft="2dp"
        android:paddingBottom="10dp"
        android:background="@drawable/white_round_button"
        />

    <EditText
        android:id="@+id/Edit_Register_Birth_Day"

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="21"
        android:inputType="number"
        android:maxLength="2"
        android:maxLines="1"
        android:textAlignment="center"
        android:layout_weight="1"
        android:paddingTop="10dp"
        android:layout_marginRight="5dp"
        android:layout_marginLeft="5dp"
        android:paddingBottom="10dp"
        android:background="@drawable/white_round_button"
        />

</LinearLayout>

2개의 답변

0 추천

생년월일 오른쪽에 리니어레이아웃을 하나더 추가하셔서 맞추시면 되지 않을까요?

 

지금 코딩을 할 수 있는 상황이아니라... 아래 같은 구조로요~

<LinearLayout>

     <이름>

     <빈리니어레이아웃>

</LinearLayout>

<LinearLayout>

     <년>

     <월>

     <일>

     <빈리니어레이아웃>

</LinearLayout>

 

 

위처럼 하시고

이름이 입력칸의 weight가 6이라면,

아래 년,월,일에 각각 2씩주고

제일 오른쪽에 같은 값을 넣어주면 해결될 것 같아요.

 

물론 주관적인 생각입니다~~

대화니 (1,120 포인트) 님이 2016년 10월 31일 답변
0 추천

흠 글로 설명하기 애매하니 xml드립니다.

분석 해보시면 이해 하실수 있을 겁니다.

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp">

    <TextView
        android:id="@+id/Text_register_Name"
        android:layout_width="80dp"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/Edit_Register_Name"
        android:layout_alignTop="@+id/Edit_Register_Name"
        android:layout_marginLeft="15dp"
        android:gravity="center_vertical"
        android:text="이름"
        android:textColor="#000000"
        android:textSize="13sp"
        android:textStyle="bold" />

    <EditText
        android:id="@+id/Edit_Register_Name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginRight="45dp"
        android:layout_toRightOf="@+id/Text_register_Name"
        android:background="@drawable/white_round_button"
        android:hint="홍 길 동"
        android:maxLines="1"
        android:paddingBottom="10dp"
        android:paddingTop="10dp"
        android:textAlignment="center" />

    <TextView
        android:id="@+id/Text_register_Birth_Year"
        android:layout_width="80dp"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/lay1"
        android:layout_alignTop="@+id/lay1"
        android:layout_marginLeft="15dp"
        android:gravity="center_vertical"
        android:text="생년월일"
        android:textColor="#000000"
        android:textSize="13sp"
        android:textStyle="bold" />


    <LinearLayout
        android:id="@+id/lay1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/Edit_Register_Name"
        android:layout_alignRight="@+id/Edit_Register_Name"
        android:layout_below="@+id/Edit_Register_Name">

        <EditText
            android:id="@+id/Edit_Register_Birth_Year"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginRight="2dp"
            android:layout_weight="1" />
        <EditText
            android:id="@+id/Edit_Register_Birth_Month"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_marginRight="2dp"
            android:layout_weight="1" />

        <EditText
            android:id="@+id/Edit_Register_Birth_Day"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:layout_weight="1"/>
    </LinearLayout>
</RelativeLayout>
ThisPlus (46,920 포인트) 님이 2016년 10월 31일 답변
글자수 제한으로 아래 에딧텍스트 속성은 제거 하였습니다.
고쳐야하거나 추가된 속성은 그대로 두었으니 참고 하시면 됩니다.
헛 ㅠ 답변 감사드립니다. 그런데 궁금한 부분이 있습니다.

제가 버튼에 대한 background를 아래와 같이 주었습니다.

그래서, 버튼이 좀 꾸며져있는 상태인데, 자세히 보면 말씀해주신 코드에

background를 써서 적용을 시켜보면, 간격이 좁아서 그런지, 버튼에 대한

이미지가 엄청 작게 나오는데 이부분을 어떻게 해결해야 할까요 ㅠ ㅠ


< white_round_button .xml 코드 >

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

<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:padding="30dp"
    android:shape="rectangle"
    >
    <corners android:radius="10dp" />
    <stroke
        android:width="2dp"
        android:color="#000000" />
    <solid
        android:color="#ffffff"
        />

</shape>
원래 제가 만들던 부분이 한줄한줄 레이아웃으로 처리하는건데
답변을 달아주신 부분은 정말 감사하지만, 생년월일 부분이 추가되어서,
이 부분을 다음 리니어 레이아웃에 한줄로 구성이 가능할까요 ㅠㅠ
에고 ㅠ ㅠ
제가 쓴 글 맨 아래쪽에 현재 디자인에서 보이는 사진을 넣어 보았습니다.
ㅠ ㅠ .. 저렇게 background를 추가해주자마자, 다시금 공간영역을 넘어버립니다..
말씀하신 코드를 참조해서 만든 제 xml 코드는 아래와 같습니다.

<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp">

        <TextView
            android:id="@+id/Text_register_Name"
            android:layout_width="80dp"
            android:layout_height="wrap_content"

            android:layout_centerVertical="true"

            android:layout_marginLeft="15dp"

            android:textStyle="bold"
            android:textColor="#000000"
            android:textSize="13sp"
            android:text="이름"/>

        <EditText
            android:id="@+id/Edit_Register_Name"
            android:maxLines="1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            android:layout_toRightOf="@+id/Text_register_Name"

            android:layout_marginRight="45dp"

            android:paddingTop="10dp"
            android:paddingBottom="10dp"

            android:background="@drawable/white_round_button"
            android:textAlignment="center"
            android:hint="홍 길 동"/>


    </RelativeLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp">

        <TextView
            android:id="@+id/Text_register_Birth_Year"
            android:layout_width="80dp"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginLeft="15dp"
            android:textStyle="bold"
            android:textColor="#000000"
            android:textSize="13sp"
            android:text="생년월일"/>


        <EditText
            android:id="@+id/Edit_Register_Birth_Year"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginRight="2dp"
            android:background="@drawable/white_round_button"
            android:layout_weight="1" />
        <EditText
            android:id="@+id/Edit_Register_Birth_Month"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:background="@drawable/white_round_button"
            android:layout_marginLeft="2dp"
            android:layout_marginRight="2dp"
            android:layout_weight="1" />

        <EditText
            android:id="@+id/Edit_Register_Birth_Day"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:background="@drawable/white_round_button"
            android:layout_marginLeft="5dp"
            android:layout_weight="1"/>


    </LinearLayout>
android:layout_toRightOf 속성은 릴레이티브레이아웃에서만 작동 합니다.
물론 대상이 되는 위젯도 같은 레이아웃안에 있어야 하는거구요.
굳이 왜 한줄을 우너하시는 모르겠지만 한줄 한줄 하시길 원하신다면 직접 크기를 다 지정해 주어야 합니다.
으 ㅠㅠ.. 4시간가량 붙잡고, 위와 아래의 간격을 좀 맞춰주고 싶은데..
무슨 이유에서인지 잘 안되네요 ㅠㅠ 자꾸 버튼이 작아지는 바람에..힘드네요..

white_round_button.xml 의 코드를 한번 아래에 올려보겠습니다 ㅠ..

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

<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:padding="30dp"
    android:shape="rectangle"
    >
    <corners android:radius="10dp" />
    <stroke
        android:width="2dp"
        android:color="#000000" />
    <solid
        android:color="#ffffff"
        />

</shape>
버튼이 작아진다는게 무슨 말인지 모르겠네요~~!
당연히 들어갈 공간이 작아지는데 버튼이 작아지는게 당연한거 아닌가요?
아 감사합니다 ㅎㅎ..; 바보같은 실수가 있었습니다.
감사합니다!
...