Button always displays on top in FrameLayout

后端 未结 7 666
醉梦人生
醉梦人生 2020-12-03 00:34

I have FrameLayout like this:



        
相关标签:
7条回答
  • 2020-12-03 01:29

    FrameLayout should be used to hold a single child view, because it can be difficult to organize child views in a way that's scalable to different screen sizes without the children overlapping each other.

    You should use LinearLayout or RelativeLayout in FrameLayout . Like this way

    <FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
       <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="changeColor"
            android:text="new button"/>
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="some text"/>
       </RelativeLayout>
    
    </FrameLayout>
    
    0 讨论(0)
提交回复
热议问题