Reputation: 5
i want edittext and send button in one row but image in other row ...but using this code edit text,send button,and image are displaying in one row..can you please tell me what should i do to display image in other row
<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="horizontal"
tools:context=".MainActivity" >
<EditText
android:id="@+id/edit_message "
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
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
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo" />
</LinearLayout>
</LinearLayout>
Upvotes: 0
Views: 159
Reputation: 1217
<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="@+id/edit_message "
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
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>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo" />
</LinearLayout>
Upvotes: 2
Reputation: 44571
You could wrap your EditText
and Button
in a LinearLayout
<LinearLayout
android:orientation="vertical"
...>
<LinearLayout
...>
<EditText
.../>
<Button
.../>
</LinearLayout>
<ImageView
.../>
</LinearLayout>
But I would probably use a RelativeLayout
<RelativeLayout
...>
<EditText
android:id="@+id/et"
.../>
<Button
android:layout_toRightOf="@id/et"
.../>
<ImageView
android:layout_below="@id/et"
.../>
</RelativeLayout>
But that also depends on exactly where you want things.
Upvotes: 2
Reputation: 1084
To get the ImageView to display in a row beneath the EditText and Button, you need to set the orientation for your outer LinearLayout to be Vertical and then wrap the EditText and Button in a Linear layout with a horizontal orientation.
Upvotes: 0