안녕하세요. 이제 막 안드로이드 개발을 공부를 시작한 초보자입니다.
뒤늦게 영어에 대한 공부 열정이 생겨서 한국이 아닌 타국에서 영어를 공부하다 재취업하기 위해서 다시금 슬슬 개발 공부를 시작하고 있는 중입니다.
요즘 모바일이 대세라 안드로이드를 공부하고 있는데요.
제가 산 책이 이클립스 위주로 되어있는데 이젠 안드로이드 스튜디오만 지원된다고 들어서 안드로이드 스튜디오에서 예제를 실습하고 있습니다.
그런데 처음부터 문제가 발생하여 이렇게 여쭈어 봅니다.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.administrator.textview.MainActivity">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="146dp"
android:background="#f88"
android:text="@string/hello_world"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/textView1"
android:layout_centerVertical="true"
android:background="#88ff88"
android:text="Hello Guys" />
<TextView
android:id="@+id/textMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/textView1"
android:layout_below="@id/textView2"
android:background="#880000ff"
android:textColor="#fff"
android:textSize="25sp"
android:text="Message" />
</android.support.constraint.ConstraintLayout>
가장 기본적인 XML 파일 수정해서 원하는 위치에 텍스트를 띄우는 예제인데요.
코드는 아래와 같습니다.
본래 결과물은 가운데 Hello Android 그 밑에 Hello Guys 그 밑에 Message 순으로 떠야하는데
위 코드로 미리보기를 보거나 ADB에 실행할 경우 Hello Android는 중앙이지만, Hello Guys와 Message는 좌측 상단에 출력이 되네요.
안드로이드 스튜디오에선 별도의 설정을 더 가져가야하는지 궁금하네요?
추가로, 미리보기에서 텍스트 위치를 옮길 경우 그 위치값이 XML에 박히던데 이렇게 띄우면 모든 크기 화면에서 동일한 결과물이 나타나나요?
(심지어 이렇게 텍스트를 옮겨서 실행해도 결과물에선 위와 동일하게 두 텍스트는 좌측 상단에 배치되네요 ㅠㅠ)
그럼 답변 기다리겠습니다.
좋은 하루 되세요 ^^