<LinearLayout 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:orientation="horizontal" >
<EditText android:id="@+id/edit_message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"
android:onClick="sendMessage" />
</LinearLayout>
以上是我想要的东西,以下就是我所拥有的,
<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" >
/*have a few more EditText, Buttons and TextView here but don't think it's relevant so didn't paste*/
<EditText
android:id="@+id/edit_percentage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText1"
android:layout_alignParentBottom="true"
android:ems="10"
android:inputType="numberDecimal"
android:text="@string/edit_percentage" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/edit_percentage"
android:layout_alignRight="@+id/editText1"
android:text="@string/button3" />
</RelativeLayout>
我确实认为这是因为relativelayout和linearlayout,但似乎不是问题。
答案 0 :(得分:1)
听起来你想要hint
。添加此行
android:hint="@string/edit_percentage"
而不是
android:text="@string/edit_percentage"
答案 1 :(得分:0)
使用android:text
属性。
<EditText android:id="@+id/edit_message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/edit_message" />