работа с вложенными представлениями? - PullRequest
2 голосов
/ 18 февраля 2011

хорошо, я пробовал несколько разных конфигураций.это продолжает падать, и я не могу понять, почему?вот код:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
   <WebView
      android:id="@+id/webview2"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" />
 <RelativeLayout>    
    <Button
        android:id="@+id/one"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginLeft="10dip"
        android:text="Video 1" />
    <Button
        android:id="@+id/two"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@id/one"
        android:text="Video 2" />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@id/two"
        android:text="Video 3" />
</RelativeLayout>
</LinearLayout>

Ответы [ 2 ]

2 голосов
/ 18 февраля 2011

Похоже, вам не хватает закрывающего тега ">" для вашего линейного макета.

2 голосов
/ 18 февраля 2011

Ваш RelativeLayout не имеет размеров;попробуйте заменить на это:

 <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

Редактировать: Ваши кнопки не отображались, потому что WebView заполнял экран, даже если вы установили его высоту, чтобы обернуть содержимое (обычно,контент больше чем экран).Итак, поскольку ваш родительский узел был LinearLayout, вы должны были также определить вес WebView и RelativeLayer.Кроме того, вы установили две и три кнопки, чтобы они появлялись слева от вашей первой кнопки, которая была нарисована всего в 10 dip от левого поля!:)

Итак, вот рефакторинг вашего кода с использованием только RelativeLayer (нет необходимости помещать его в LinearLayout):

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
   <WebView
      android:id="@+id/webview2"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" android:layout_above="@+id/one"/>   
    <Button
        android:id="@+id/one"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginLeft="10dip"
        android:text="Video 1" />
    <Button
        android:id="@+id/two"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_toRightOf="@id/one"
        android:text="Video 2" />
    <Button
    android:id="@+id/three"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_toRightOf="@id/two"
        android:text="Video 3" />
</RelativeLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...