且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Facebook的应用程序为Android创建登录布局像

更新时间:2023-10-25 17:44:28

他们正在做的,相对布局,adjustResize,和android:layout_centerVertical。基本上,他们有他们的主要布局的线性布局,在它的内部3同等权重相对布局。每个设置为0dp的高度,所以他们采取了屏幕的平等三分之二。顶部RelativeLayout的持有徽标,垂直居中。中间保持登录字段和按钮,垂直1中心在另一个的顶部。底部的一方的版权文本,对齐底部。最终的结果是,当键盘出现时,3个相对布局得到调整大小来利用新屏幕的1/3。然后它们的元素都集中在新的屏幕。

They're doing it with relative layouts, adjustResize, and android:layout_centerVertical. Basically, they have a linear layout for their main layout, with 3 equally weighted relative layouts inside of it. Each is set to 0dp height, so they take up equal thirds of the screen. The top RelativeLayout holds the logo, centered vertically. The middle holds the login fields and button, centered vertically one on top of the other. The bottom one holds the copyright text, aligned to bottom. The end result is that when the keyboard comes up, the 3 relative layouts get resized to take 1/3 of the new screen. Then their elements are centered in the new screen.

记住,你所需要的adjustResize窗口模式得到这个,如果你使用平移它只是移动和图案就会滚动偏离中心。

Remember you need the adjustResize window mode to get this, if you use pan it will just move up and the logo will scroll off center.