2016-12-30 206 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>