使用下面的代碼
android:layout_height="wrap_content"
你真正確保您的佈局看你想要的方式在地球上每一個Android手機上
對於間距,Android定義了兩個屬性:android:layout_margin和android:padding。 android:layout_margin屬性定義容器的間距,而android:padding則定義視圖的間距。
機器人:填充 - 定義的內容的間隔上的控制的所有四個側面。要分別定義每邊的填充,請使用android:paddingLeft,android:paddingRight,android:paddingTop和android:paddingBottom。
機器人:paddingTop - 定義的內容和所述控制
機器人的頂部之間的間距:paddingBottom來 - 定義的內容和控件的底部之間的間距。
android:paddingLeft-定義內容和控件左側之間的間距。
android:paddingRight-定義內容和控件右側之間的間距。
* 編輯的代碼一定要 「mainactivity到任何您的活動名稱有」 更改名稱*
<?xml version="1.0" encoding="utf-8"?>
<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=".MainActivity" >
<TextView
android:id="@+id/textview_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+string/email" />
<EditText
android:id="@+id/textinput_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textEmailAddress" />
<TextView
android:id="@+id/textview_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+string/password" />
<EditText
android:id="@+id/textinput_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/button_exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+string/cancel" />
<Button
android:id="@+id/button_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+string/ok" />
</LinearLayout>
</RelativeLayout>
你的答案完全工作下面的代碼
<?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="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/textview_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+string/email" />
<EditText
android:id="@+id/textinput_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textEmailAddress" />
<TextView
android:id="@+id/textview_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+string/password" />
<EditText
android:id="@+id/textinput_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="28.05" >
<Button
android:id="@+id/button_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:gravity="center_vertical"
android:text="@+string/ok" />
<Button
android:id="@+id/button_exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@+string/cancel" />
</RelativeLayout>
</LinearLayout>
你能告訴我新的代碼嗎? – omega
明確告訴我你想要什麼........你已經在你的相對佈局xml代碼中使用了android:layout_height =「wrap_content」 –
嘗試添加...在你的代碼中填充...查看編輯答案 –