Joe Winfield
Joe Winfield

Reputation: 829

working with nested views?

ok i've tried several different configurations. this keeps crashing and i can't see why? here is the code:

<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>

Upvotes: 2

Views: 3108

Answers (2)

Adinia
Adinia

Reputation: 3731

Your RelativeLayout have no dimensions; try replacing with this:

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

Edit: Your buttons were not shown because the WebView was filling the screen, even if you set its hight as to wrap the content (usually, the content is larger than the screen). So, as your node parent was a LinearLayout, you should have also seted the weight of the WebView and of the RelativeLayer. Also, you have seted your two and three buttons to appear at the left of your first button, which was draw at only 10dip of the left margin! :)

So, here is a refactoring of your code, using only a RelativeLayer(there is no need to put it inside a 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>

Upvotes: 2

Kingpin
Kingpin

Reputation: 292

It looks like you're missing a closing tag ">" for your Linear Layout.

Upvotes: 2

Related Questions