저는 정말로 안드로이드에서 새내기입니다. 그냥 그림이있는 textviews로 레이아웃을 만들고 싶습니다.Textviews가 정확한 위치에 없습니다.
나는 그것을 만들었으며, 내 편집자가 좋아 보인다. (나는 eclipse/adt를 사용하고있다.)
내가 처음 시도했을 때 결과는 끔찍했습니다 (그림 참조). 그 후 다른 설정에서 시도했는데, 여전히 끔찍한 것입니다.
저는 아시다시피, dp는 독립을위한 것이지만, 나는 그렇지 않습니다. 그러나 나는 뭔가 잘못했다고 생각합니다.
내가 도와 주며, 나에게 무엇을 잘못했는지, 그리고 왜 텍스트 뷰와 그림이 움직이는 지 알려주십시오. 사진에
왼쪽에서 오른쪽으로 :
- 편집기
- 에클 레어, 3.3 QVGA 320 × 480 MDPI
- 젤리 콩 3.2 WQVGA 240x400 LDPI
그리고 내 코드 :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/quizLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/quiz_background"
tools:context=".Quiz" >
<Button
android:id="@+id/btnGo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="36dp"
android:text="@string/go" />
<TextView
android:id="@+id/tvQuestion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="19dp"
android:layout_marginTop="60dp"
android:text="@string/question" />
<TextView
android:id="@+id/tvPoints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tvQuestion"
android:layout_below="@+id/tvQuestion"
android:layout_marginTop="31dp"
android:text="@string/points" />
<ImageView
android:id="@+id/imgCarHolder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tvPoints"
android:layout_below="@+id/tvPoints"
android:layout_marginTop="26dp"
android:contentDescription="@string/dummy" />
</RelativeLayout>
다른 화면 크기에 대해 다른 화면 레이아웃을 만들어야합니다. 다른 화면에 대해 dp 값이 변경되면 별도로 설계해야합니다. –
은 xhdpi, ldpi, mdpi 및 hdpi에서 성공하고 4 장의 사진을 만들고 싶다면 4 가지 레이아웃에서 4 번 모두 뷰를 정의해야합니다. – vaso123
hight 또는 width 또는 레이아웃 파일의 다른 모든 공간 컨텍스트에 고정 값을 사용하는 경우 각 화면 크기에 대해 개별적으로 이동하는 것이 좋습니다. 예를 들어 35 dp는 해상도가 360 * 480 인 화면과 480 * 640입니다. 따라서 큰 범위의 상수를 사용하는 경우 화면이 이상하게 보입니다. –