TextView中的和预期EdidText不是对齐 [英] TextView's and EdidText's not align as expected

查看:272
本文介绍了TextView中的和预期EdidText不是对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我尝试做一个简单的报名参加活动,但如预期我的观点是对齐没有。

So im trying to make a simple sign up activity but my Views are aligned not as expected.

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.mylifeinformationsharedsocial.SignUpActivity" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/username_id"
    android:text="@string/username_text"
    android:textSize="20sp"
    />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/username_edit_text_id"
    android:hint="@string/username_hint_texts"
    android:layout_toRightOf="@id/username_id"
    android:layout_toEndOf="@id/username_id"
    />

 <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/password_id"
    android:text="@string/password_text"
    android:textSize="20sp"
    android:layout_below="@id/username_edit_text_id"
    />

<EditText
    android:id="@+id/password_edit_text_id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="textPassword"
    android:hint="@string/passworde_hint_texts"
    android:layout_toRightOf="@id/password_id"
    android:layout_toEndOf="@id/password_id"
    android:layout_below="@id/username_edit_text_id"
    />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/email_id"
    android:text="@string/email_text"
    android:textSize="20sp"
    android:layout_below="@id/password_id"
    />

<EditText
    android:id="@+id/email_edit_text_id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="textEmailAddress"
    android:hint="@string/email_hint_text"
    android:layout_toRightOf="@id/email_id"
    android:layout_toEndOf="@id/email_id"
    android:layout_below="@id/password_edit_text_id"
    />

<Button
    android:id="@+id/sign_up_button_id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/sign_up_button_text"
    android:layout_below="@id/email_id"
    />

图形布局:

在这里输入的形象描述

我不能似乎发现什么不妥的地方。任何帮助将是非常美联社preciated。
问题是与向下所看到的图片电子邮件。
它的pretty两岸前锋,但显然不是。

I cant seem to find whats wrong with it. Any help will be very appreciated. The problem is with the Email downwards as seen in the pic. Its pretty strait forward but apparently not.

推荐答案

也许你可以试试这样:

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/username_id"
    android:text="@string/username_text"
    android:textSize="20sp"
    />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/username_edit_text_id"
    android:hint="@string/username_hint_texts"
    android:layout_toRightOf="@id/username_id"
    android:layout_toEndOf="@id/username_id"
    />

 <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/password_id"
    android:text="@string/password_text"
    android:textSize="20sp"
    android:layout_below="@id/username_edit_text_id"
    />

<EditText
    android:id="@+id/password_edit_text_id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="textPassword"
    android:hint="@string/passworde_hint_texts"
    android:alignRight = "@id/username_edit_text_id"
    android:layout_below="@id/username_edit_text_id"
    />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/email_id"
    android:text="@string/email_text"
    android:textSize="20sp"
    android:layout_below="@id/password_id"
    />

<EditText
    android:id="@+id/email_edit_text_id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="textEmailAddress"
    android:hint="@string/email_hint_text"
    android:alignRight = "@id/password_edit_text_id"
    android:layout_below="@id/password_edit_text_id"
    />

<Button
    android:id="@+id/sign_up_button_id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/sign_up_button_text"
    android:layout_below="@id/email_id"
    />

使用 toRightOf 我代替 alignRight 因此,所有的EditText 将右对齐。

Instead of using toRightOf I used alignRight so all EditText would be right aligned.

这将工作做好为你的情况(如果你只有这些行),否则你应该调整所有的EditText 最右边的。

This will work well for your case (if you have only these rows), otherwise you should align all EditText to the right most one.

这篇关于TextView中的和预期EdidText不是对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆