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

RelativeLayout 태그 위치문제 관련 문의 드립니다.

0 추천

안녕하세요.

안드로이드 책을 보며 예제를 따라하다 책에서 말하는 결과나 나오지 않아 문의 합니다. 

책과 웹페이지에서 제공하는 소스도 확인해서 그대로 해보았으나,

 EditText가 TextView 바로옆에 위치해지지가 않네요.

도움 부탁드립니다.

<?xml version="1.0" encoding="utf-8"?>
<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:padding="10dp"
    android:background="@drawable/login_background"
    tools:context="com.example.kyc.mystudy6.MainActivity">

    <TextView
        android:id="@+id/titleLabel"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:layout_alignParentTop="true"
        android:gravity="center_horizontal"
        android:text="식당 찾기 도우미"
      android:textColor="#ffffffff"
        android:textStyle="bold"
        android:textSize="24dp"
    />

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:padding="10dp"
        android:background="#aaffffff"
        >

        <TextView
            android:id="@+id/usernameLabel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="4dp"
            android:text="Username : "
            android:textColor="#ff222222"
            android:textSize="18dp"
            />
        <EditText
            android:id="@+id/usernameEntry"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/usernameLabel"
            android:layout_alignBaseline="@id/usernameLabel"
            android:layout_marginLeft="4dp"
            />
    </RelativeLayout>
</RelativeLayout>
Kim.droid (200 포인트) 님이 2016년 3월 9일 질문

1개의 답변

0 추천
 
채택된 답변
EditText의 width가 match_parent라서 안되는것 같네요 wrap_content나 작은 사이즈로 변경해서 한번해보세요,

LinearLayout으로 구현해서 android:orientation 을 horizontal로 변경하시면 나오게 하는 방법도있구요,
캬옹이 (37,920 포인트) 님이 2016년 3월 10일 답변
Kim.droid님이 2016년 3월 30일 채택됨
감사합니다. 해결 되었네요. wrap_content는 되지만 사이즈가 작게 나와서 말씀해주신방법으로 사이즈 변경 했습니다. 감사합니다.
...