Domanda

I have a frame layout. The height of the frame layout is 400px. I have a button on the bottom of the layout. Now I want a second button on the top of the frame layout. This is with one button.

    <FrameLayout
        android:id="@+id/framelayout1"          
        android:layout_width="0dp"
        android:layout_height="fill_parent" 
        android:layout_weight="1" >


    <ImageButton
        android:id="@+id/smileButton"
        android:background="@drawable/smile_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:layout_gravity="bottom|right"
        android:adjustViewBounds="true"
        android:scaleType="centerInside" />

            </FrameLayout> 

And this is with the two buttons. It's not working. I don't see the second button on the top.

    <FrameLayout
        android:id="@+id/framelayout1"          
        android:layout_width="0dp"
        android:layout_height="fill_parent" 
        android:layout_weight="1" >


    <ImageButton
        android:id="@+id/smileButton"
        android:background="@drawable/smile_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:layout_gravity="top|right"
        android:adjustViewBounds="true"
        android:scaleType="centerInside" />

    <ImageButton
        android:id="@+id/smileButton"
        android:background="@drawable/smile_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:layout_gravity="bottom|right"
        android:adjustViewBounds="true"
        android:scaleType="centerInside" />

            </FrameLayout> 
È stato utile?

Soluzione

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/framelayout1"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_weight="1" >

    <ImageButton
        android:id="@+id/smileButton"
        android:background="@drawable/smile_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:layout_gravity="top|right"
        android:adjustViewBounds="true"
        android:scaleType="centerInside" />

    <ImageButton
        android:id="@+id/smileButton"
        android:background="@drawable/smile_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:layout_gravity="bottom|right"
        android:adjustViewBounds="true"
        android:scaleType="centerInside" />

            </FrameLayout>

try this

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top