0

第一种方式:

<Button
    android:id="@+id/btnLogin"
    style="@style/btnStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/btnFacebook"
    android:layout_alignRight="@+id/btnFacebook"
    android:layout_below="@id/etPassword"
    android:layout_centerInParent="true"
    android:onClick="goHome"
    android:text="Login"/>

<Button
    android:id="@+id/btnFacebook"
    style="@style/btnFacebook"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/textOR"
    android:layout_marginTop="10dp"
    android:onClick="facebookSignUp"
    android:text="     Signup with Facebook     "/>


<Button
    android:id="@+id/btnGooglePlus"
    style="@style/btnGoogle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/btnFacebook"
    android:layout_alignRight="@+id/btnFacebook"
    android:layout_below="@id/btnFacebook"/>

第二种方式:

<Button
    android:id="@+id/btnLogin"
    style="@style/btnStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/btnFacebook"
    android:layout_alignRight="@id/btnFacebook"
    android:layout_below="@id/etPassword"
    android:layout_centerInParent="true"
    android:onClick="goHome"
    android:text="Login"/>

<Button
    android:id="@id/btnFacebook"
    style="@style/btnFacebook"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/textOR"
    android:layout_marginTop="10dp"
    android:onClick="facebookSignUp"
    android:text="     Signup with Facebook     "/>


<Button
    android:id="@+id/btnGooglePlus"
    style="@style/btnGoogle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@id/btnFacebook"
    android:layout_alignRight="@id/btnFacebook"
    android:layout_below="@id/btnFacebook"/>

第三种方式:

<Button
    android:id="@+id/btnLogin"
    style="@style/btnStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@id/btnFacebook"
    android:layout_alignRight="@id/btnFacebook"
    android:layout_below="@id/etPassword"
    android:layout_centerInParent="true"
    android:onClick="goHome"
    android:text="Login"/>

<Button
    android:id="@+id/btnFacebook"
    style="@style/btnFacebook"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/textOR"
    android:layout_marginTop="10dp"
    android:onClick="facebookSignUp"
    android:text="     Signup with Facebook     "/>


<Button
    android:id="@+id/btnGooglePlus"
    style="@style/btnGoogle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@id/btnFacebook"
    android:layout_alignRight="@id/btnFacebook"
    android:layout_below="@id/btnFacebook"/>

两个问题:

  1. 三种初始化方式的输出

btn脸书

是同样的。如何?

  1. 由于输出相同,意味着 XML Parser 编译结果相同。那么资源的初始化究竟是如何完成的以及它们是如何附加到 ViewTree 的呢?

感谢任何带有解释的官方文档。提前致谢 :)

4

1 回答 1

1

从这里

顺序不会有任何区别。

好像视图相同,但第三种方式不起作用,因为 btnFacebook 没有在 btnLogin 之前声明。所以会显示编译错误。第三种方法将在稍作更改后起作用,请参阅链接。欲了解更多信息

于 2016-08-12T05:23:36.317 回答