2015-06-20 19 views
0

這是一個Android問題。如何將按鈕添加到與我的圖片位置相同的Android Frame Layout中(居中顯示在屏幕的底部4)?

如何將按鈕添加到與我的圖片相同位置的框架佈局?

我想加上的幀結構(其中有一個背景圖像和沒有標題欄)的頂部的按鈕,像這樣:

enter image description here

這是我的佈局的整個代碼,以便遠。我添加了哪些代碼來放置圖片中的按鈕?

activity_home_page.xml:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" 
    tools:context=".HomePage"> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:src="@drawable/my_background_image" 
     android:scaleType="fitXY"> 
    </ImageView> 



</FrameLayout> 

我如何加入一個按鈕的幀結構,在相同的位置,我的圖片?

+1

你到底在找什麼? – NarenderNishad

+0

如何在與圖片中相同位置的框架佈局中添加按鈕? –

+0

哪個控件是你在後臺使用的? –

回答

3

我試過&想出了一個解決方案。

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" 
    tools:context=".HomePage"> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@drawable/mod_minecraft" 
     android:scaleType="fitXY"> 
    </ImageView> 

    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1"></LinearLayout> 

     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1"></LinearLayout> 

     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1"></LinearLayout> 

     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:gravity="center" 
      android:layout_weight="1"> 

      <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="New Button" 
       android:id="@+id/button" /> 
     </LinearLayout> 
    </LinearLayout> 

</FrameLayout> 
+1

謝謝!它嘗試了它,並且它完美地工作,並且完全按照我想要的那樣做。 –

+1

@RockLee樂意幫助你! – NarenderNishad

相關問題