2012-07-17 74 views
-4

我是新开发的android开发人员,经过几年严格的C++编程,例如ogl,dx,sfml等apis,我真的对所有这些布局和东西感到头痛。如何使用Android SDK实现这种布局?

基本上我问你如何实现以下设置:

enter image description here

我试过放在一起一些随机的布局和了所见即所得的编辑器修复它,但是这件事情只是催着我香蕉,我不能让它起作用。感觉就像我所做的一样,编辑的行为有所不同。

如果有人可以给我一些提示,那就太棒了。

顺便说一句,我可以创建一个事件形式[Activity在这种情况下]称为每个帧? [没有游戏循环吸!]

回答

0

我宁愿向下打破一切成布局彼此之内。这里将是您需要的一个例子,但有很多方法可以定义完全相同的东西。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Large Text" 
     android:layout_marginTop="20dp" 
     android:layout_gravity="center" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     > 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="300dp" 
      android:layout_height="300dp" 
      android:layout_alignParentTop="true" 
      android:layout_centerHorizontal="true" 
      android:src="@drawable/icon" /> 

     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Large Text" 
      android:layout_centerHorizontal="true" 
      android:layout_alignBottom="@+id/imageView1" 
      android:textAppearance="?android:attr/textAppearanceLarge" /> 

    </RelativeLayout> 

    <ImageButton 
     android:id="@+id/imageButton1" 
     android:layout_width="200dp" 
     android:layout_height="50dp" 
     android:src="@drawable/icon" 
     android:layout_marginTop="50dp" 
     android:layout_gravity="center"/> 

</LinearLayout> 
+0

谢谢!在你的帮助下找出它。看起来我得手动键入边距和大小,因为他们的编辑器只是简单地吹... ... BTW:爱这个社区减少我的线程<3 – user1255410 2012-07-17 19:56:57

+0

雅拖放的想法是伟大的,但实际使用非常令人沮丧。我通常会在屏幕上放下几个项目,然后从代码一侧完全重做屏幕。线性布局可能非常有限,但相对布局会增加大量的定制。尝试在布局中输入“android:”,然后让它坐在一个分钟和拇指的列表中,你可以看到所有相关布局添加的可能性。如果你使用的是我不知道其他编辑器的eclipse。 – 2012-07-17 20:05:18