Android Layout Позиционирование - PullRequest
       0

Android Layout Позиционирование

0 голосов
/ 16 февраля 2012

Я пытаюсь создать макет, в котором у меня есть изображение и справа от изображения имя пользователя, затем также справа, но ниже имени пользователя дата рождения, а затем местоположение пользователя под ним.Хотя не уверен, как правильно расположить предметы.В моем коде ниже вы можете видеть, что я пытался объединить layout_below и layout_toRightOf.При первом просмотре текста оно правильно позиционирует имя, но когда я добавляю два других, все они оказываются в верхнем правом углу.

Правильно ли я полагать, что использование toRightOf, за которым следует ниже, отменяетпервый макет.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content">
    <ImageView
        android:id="@+id/profile_image"
        android:src="@drawable/ic_tab_white"
        android:layout_width="150dp"
        android:layout_height="150dp" 
        android:contentDescription="@string/image_description">
    </ImageView>
    <TextView 
        android:id="@+id/name" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/unset"
        android:layout_toRightOf="@id/icon_image" >
   </TextView>
   <TextView 
        android:id="@+id/dob" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/unset"
        android:layout_toRightOf="@id/icon_image"
            android:layout_below="@id/name">
   </TextView>
   <TextView 
        android:id="@+id/location" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/unset"
        android:layout_toRightOf="@id/icon_image"
            android:layout_below="@id/dob">
   </TextView>
</RelativeLayout>

Ответы [ 2 ]

0 голосов
/ 16 февраля 2012

У вас есть опечатка, идентификатор вашего imageView которой равен @ + id / profile_image, а в остальной части макета вы ссылаетесь на "@ id / icon_image". Попробуйте с:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout 
      xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content">
      <ImageView
          android:id="@+id/profile_image"
          android:src="@drawable/ic_tab_white"
          android:layout_width="150dp"
          android:layout_height="150dp" 
          android:contentDescription="@string/image_description">
      </ImageView>
      <TextView 
          android:id="@+id/name" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="@string/unset"
          android:layout_toRightOf="@id/profile_image" >
     </TextView>
     <TextView 
          android:id="@+id/dob" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="@string/unset"
          android:layout_toRightOf="@id/profile_image"
              android:layout_below="@id/name">
     </TextView>
     <TextView 
          android:id="@+id/location" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="@string/unset"
          android:layout_toRightOf="@id/profile_image"
              android:layout_below="@id/dob">
     </TextView>
  </RelativeLayout>
</ScrollView>
0 голосов
/ 16 февраля 2012

просто используйте что-то вроде этого psuedocode

<scrollview>
    <linearlayout> vertical
        <Linearlayout> horizontal
            <imageview>
            <linearlayout> vertical
                <textview>
                <textview>
                <textview>
            </linearlayout>
        </linearlayout>
    </linearlayout>
</scrollview>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...