2016-12-30 249 views
1

我試圖在XML文件中使用圖形界面和android:layout_alignParentLeft來移動按鈕,無論如何它不起作用。我的Android Studio版本是2.2.3。你有過這個問題嗎?我無法移動框架佈局中的按鈕

enter image description here

+0

請出示你的XML代碼.. –

回答

1

如果你不得不使用的FrameLayout(例如,在工具欄或左右),你只有一個元素(或少量)與(按鈕)來操作,您可以使用android:layout_gravity=""屬性中的FrameLayout對齊元素。

如果你在你的佈局幾個要素,你可以:1)變化的FrameLayout到的RelativeLayout或2)包裝所有物品進入相對佈局和設置參數,以match_parent

<FrameLayout 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/colorPrimary"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <TextView 
      android:text="@string/app_name" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true"/> 
    </RelativeLayout> 
    </FrameLayout>