2013-05-07 116 views
0

我不知道我应该给这个标题什么。但我的问题是在eclipse中使用android应用程序时。使用activity_main屏幕时,当我从工具栏上的东西放在屏幕上,它的行为不同,我没有要描述的话。例如,我正在使用带有两个单选按钮的标签和广播组。当我想把它们放在屏幕上时,单选按钮对齐方式设置为水平我只是不能做到这一点,如果我将下面的东西移动到随机位置,其次我将它用作广播组的标题,如果我放置那也从屏幕上消失了。我移动东西一个像素,他们自己移动一些随机像素。它不是一个固定的位置,它们移动到我无法控制的任何地方。使用activity_main.xml时出现android问题

我不知道如何处理这些问题,这真的让我失望。

请帮帮我。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainScreen" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/type" /> 

    <RadioGroup 
     android:id="@+id/radioGroup1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignTop="@+id/textView1" 
     android:layout_marginLeft="26dp" 
     android:layout_toRightOf="@+id/textView1" > 

     <RadioButton 
      android:id="@+id/radio0" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:checked="true" 
      android:text="RadioButton" /> 

     <RadioButton 
      android:id="@+id/radio1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="RadioButton" /> 
</RadioGroup> 
+3

发布您的acivity_main.xml我们喜欢这里的代码。很多。 – TronicZomB 2013-05-07 13:11:37

+1

我不是很确定你在说什么,但我会建议不要使用图形界面来构建你的'Layouts'。我几乎从不使用它。自己编写代码要容易得多,给你更多的控制权,并且会帮助你理解这些属性,以及evreything如何更好地工作 – codeMagic 2013-05-07 13:12:03

+1

如果我的理解正确,那么在Eclipse中使用GUI布局编辑器。对于一些基本的东西来说这是可以的,但你真的想直接使用XML并在模拟器或设备上进行测试。 – 2013-05-07 13:13:21

回答

2

检查查看正在使用哪种类型的布局,线性布局,相对布局,列表视图。

谷歌Android布局链接 http://developer.android.com/guide/topics/ui/declaring-layout.html

没有绝对的布局,你不会想一个。您必须创建布局,操作系统将根据设备大小和分辨率来定位您的控件。

+0

谢谢@Kyght ...真的很感谢:) – Amjad 2013-05-07 13:28:12

+0

没问题@UsmanSharifAmjadKhan – Kyght 2013-05-07 13:37:38

1


据我了解你的问题,你有使用Android中的布局编辑器的困难。 我建议你使用XML选项卡而不是布局编辑器。完全学习它可能需要一些时间,但我发现布局编辑器太麻烦了。在xml编辑器中,您还有更多选项来自定义布局。

+0

我很想做到这一点,但因为我是一个天真的用户...不知道哪个属性设置,如果我使用按钮例如..这只是一个例子,有很多组件,他们大厅有不同的属性...我这样做是为了了解有关属性和东西的一切..谢谢:) – Amjad 2013-05-07 13:25:48

+0

也许这篇文章会帮助你:http:// stackoverflow。 com/questions/1360134/is-there-any-android-xml-documentation – 2013-05-07 13:30:15

1

如果上面的代码是你的整个xml,那么你的问题的一部分是你永远不会关闭你的RelativeLayut。您需要如下内容:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainScreen" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/type" /> 

    <RadioGroup 
     android:id="@+id/radioGroup1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignTop="@+id/textView1" 
     android:layout_marginLeft="26dp" 
     android:layout_toRightOf="@+id/textView1" > 

     <RadioButton 
      android:id="@+id/radio0" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:checked="true" 
      android:text="RadioButton" /> 

     <RadioButton 
      android:id="@+id/radio1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="RadioButton" /> 
</RadioGroup> 
</RelativeLayout> 
+0

谢谢你的努力,但是因为我有对齐方面的问题,所以我从屏幕上删除了所有内容 – Amjad 2013-05-07 13:31:46

+0

好,祝你好运 – TronicZomB 2013-05-07 13:36:38