Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在Eclipse上使控件相互对齐_Android_Eclipse_Alignment - Fatal编程技术网

Android 如何在Eclipse上使控件相互对齐

Android 如何在Eclipse上使控件相互对齐,android,eclipse,alignment,Android,Eclipse,Alignment,我是Eclipse和Android的新手,需要将控件彼此对齐 在VisualStudio中,我可以轻松地对齐控件并在它们之间分配空间。在Eclipse中如何实现这一点 我得到了这个xml。只是将它们拖放到布局中。必须有一个简单的方法来调整和分配。特别怀疑 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tool

我是Eclipse和Android的新手,需要将控件彼此对齐

在VisualStudio中,我可以轻松地对齐控件并在它们之间分配空间。在Eclipse中如何实现这一点

我得到了这个xml。只是将它们拖放到布局中。必须有一个简单的方法来调整和分配。特别怀疑

<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="com.example.sbs.MainActivity" >
<!-- Ders adları -->
<TextView
    android:id="@+id/lblTurkce"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="42dp"
    android:layout_marginTop="78dp"
    android:text="@string/Turkce" />

  <TextView
      android:id="@+id/lblDil"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/lblTarih"
      android:layout_alignParentBottom="true"
      android:layout_marginBottom="166dp"
      android:text="@string/ingilizce" />

  <TextView
      android:id="@+id/lblMatematik"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/lblTurkce"
      android:layout_below="@+id/lblTurkce"
      android:layout_marginTop="15dp"
      android:text="@string/Matematik" />

  <TextView
      android:id="@+id/lblFen"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/lblMatematik"
      android:layout_below="@+id/lblMatematik"
      android:layout_marginTop="18dp"
      android:text="@string/FenveTeknoloji" />

  <TextView
      android:id="@+id/lblTarih"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/lblFen"
      android:layout_below="@+id/lblFen"
      android:layout_marginTop="24dp"
      android:text="@string/tarih" />

  <TextView
      android:id="@+id/lblDin"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/lblTarih"
      android:layout_centerVertical="true"
      android:text="@string/din" />


所以,这是一个朋友做的,我也开始做,我可以很好地调整东西

因此,您必须做的是处理线性布局及其属性方向属性

现在我不知道你们想做什么,但我可以给你们一个小例子,希望你们能理解我在这里写的东西

假设你有3个文本视图,你想把它们像两个一样排列在屏幕顶部,最后一个,你想在两个已经对齐的按钮下面。它看起来很像一个金字塔,但顶部朝下

您可以这样做:前两个文本视图将放置在一个线性布局中,方向设置为水平(这样第二个文本视图将位于第一个文本视图的右侧,但在同一行上(因此与第一个文本视图的右侧对齐)

现在,另一个不必包含在LinearLayout中,但是第一个LinearLayout(具有第一个和第二个TextView)和第三个TextView必须包含在方向垂直的LinearLayout中。这样,第三个TextView就位于包含两个TextView的LinearLayout的下方


如果需要更多说明,请与我联系。

RelativeLayout提供了各种可以使用的对齐属性。例如,如果要在RelativeLayout中对齐两个不同文本视图的左边缘,可以使用layout\u alignLeft属性,如下所示:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textViewOne"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dp"
        android:text="Text One"/>

    <TextView
        android:id="@+id/textViewTwo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/textViewOne"
        android:layout_alignLeft="@id/textViewOne"
        android:text="Text Two"/>

</RelativeLayout>


请注意,我强制第一个文本视图留有左边距,并且第二个文本视图与第一个文本视图正确左对齐。如果您将第二个文本视图的layout_alignLeft属性去掉,它将与父文本的左边缘对齐。

谢谢您的回答,但这并不是我真正想要的。我正在寻找一种简单的方法来解决这个问题o放置控件。检查此图像,还记得这些按钮吗?嗯,那么你要找的是某种SeekBar?或切换按钮?你是用XML做的。我有50个TextView元素。全部选中。现在我需要一个快捷方式或IDE按钮来为我创建此XML。你使用Visual Studio吗?检查我上面发送的图像。我知道我可以用我想让我的IDE为我做这件事。有什么建议吗?对不起,关于如何使用VS中的布局编辑器,我没有答案。我从来没有使用过一个我想要的方式工作的编辑器,所以我求助于自己编辑xml。