,为您在屏幕上创建一个登录的情况下,它不是真正的问题,因为它是一个相对容易的屏幕设计。我个人喜欢使用XML来设计我的布局,并且从来没有见过使用onDraw
方法完成。
作为@codeMagic的我给你的建议是学习如何使用和操作RelativeLayouts
,因为这些将阻止你创建真正不被推荐并且需要很长时间加载的级联布局。
当我开始为Android编程,我发现LinearLayout
是最容易理解和使用,但使用它会给我带来很多LinearLayouts
一个LinearLayouts
内部复杂的屏幕designz,后来随着使用的RelativeLayout的我意识到,在大多数情况下一个RelativeLayout
可以取代许多级联线性。
你的情况,你可以做一些事情这样的:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@drawable/drop_down_icon" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/imageView1" >
</EditText>
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/editText1" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText2"
android:layout_centerHorizontal="true"
android:text="Button" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button1"
android:layout_centerHorizontal="true"
android:text="TextView" />
</RelativeLayout>
所有东西剩下的只是添加所需padings和利润。
使用XML,我认为使用垂直线性布局作为主视图,并将徽标嵌入第一行,并在第二行嵌入相对布局,以便您可以制作所需内容。当然,你可以为圆角矩形制作自己的资产,我相信 – adarsh 2013-03-10 00:07:55