Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6767591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:58:08+00:00 2026-05-26T14:58:08+00:00

I use this layout as a dialog. The problem is that the button appears

  • 0

I use this layout as a dialog. The problem is that the button appears to the right of the text.I tried with padding,position,gravity to make it appear UNDER the textview but I failed.
Hope you can help me….

     <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/layout_root"
      android:orientation="horizontal"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:padding="10dp"
      >
      <ImageView 
       android:id="@+id/image"
       android:layout_width="wrap_content"
       android:layout_height="fill_parent"
       android:layout_marginRight="10dp"
       />
      <TextView android:id="@+id/text"
      android:layout_width="wrap_content"
      android:layout_height="fill_parent"
      android:textColor="#FFF"
      />

      <Button
      android:id="@+id/ok"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:text="ok"

      />
      </LinearLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:58:09+00:00Added an answer on May 26, 2026 at 2:58 pm

    You’re using a LinearLayout in a horizontal orientation. That means it will list all views in a row horizontally in the order you put them.

    You obviously want the image next to the text, so there are two ways to do that. You can use two LinearLayouts. The top one in a vertical orientation and the inner in a horizontal. The inner will contain the image and text. The outer will contain the inner and the button.

    The second is to use RelativeLayout which allows you to set attributes like layout_below which will place the button below the text no matter where you put the text.

    With two LinearLayouts:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/layout_root"
          android:orientation="vertical"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:padding="10dp"
          >
         <LinearLayout
         android:id="@+id/linearLayout1"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:orientation="horizontal"
         >
            <ImageView
            android:id="@+id/image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dp"
            android:src="@drawable/ic_launcher" />
            <TextView
                android:id="@+id/text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#FFF" />
         </LinearLayout>
         <Button
            android:id="@+id/ok"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="ok"
          />
    </LinearLayout>
    

    With RelativeLayout (simpler):

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/layout_root"
        android:layout_width="fill_parent"
        android:layout_height="fil_parent"
        android:padding="10dp" >
            <ImageView
                android:id="@+id/image"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="10dp"
                android:src="@drawable/ic_launcher" />
            <TextView
                android:id="@+id/text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@id/image"
                android:layout_toRightOf="@id/image"
                android:text="@string/app_name"
                android:textColor="#FFF" />
            <Button
                android:id="@+id/ok"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@id/image"
                android:layout_below="@id/text"
                android:text="ok" />
    </RelativeLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use this layout with two 50% column width instead. But it
I am using a tablayout nested inside a dialog that I use for a
I created a custom dialog that extends Dialog. One button on that the dialog
I've got this dialog (I'm simplifying my use case): class EditShoppingListDialog extends AlertDialog {
use this website a lot but first time posting. My program creates a number
I use this tool called Lazy C++ which breaks a single C++ .lzz file
I use this line in my .htaccess file to automatically add a trailing slash
I use this code to update data in database table. Can reuse same code
I use this $query = SELECT * FROM info ORDER BY id DESC limit
We use this small utility method. But we don't like it. Since it's not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.