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 8495657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:38:00+00:00 2026-06-10T23:38:00+00:00

I need to add views to a vertical Linearlayout at bottom programmatically. (Yes we

  • 0

I need to add views to a vertical Linearlayout at bottom programmatically. (Yes we know that, it’s in the title).

Ok : i can add views to the linearlayout, it’s not a problem. But it’s for a chat, so i need to add views at the bottom for each message which is displayed. I don’t find any attributes to the LinearLayout to do that.

Adding messages :

mHandler.post(new Runnable() {
            @Override
            public void run() {
                TextView message = new TextView(ChatActivity.this);
                String[] splitMessage = text.split(":");
                message.setText(splitMessage[0]+"\n"+splitMessage[1]);
                message.setGravity(Gravity.LEFT);
                message.setMaxWidth(200);
                message.setBackgroundColor(getResources().getColor(android.R.color.tertiary_text_light));
                message.setTextColor(getResources().getColor(android.R.color.black));
                message.setSingleLine(false);
                mLayout.addView(message);
            }
        });

chat_layout.xml :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/live_obs_mainLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/empty"
    android:orientation="vertical" >

    <ScrollView
        android:id="@+id/chat_layout"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="10" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:isScrollContainer="tue"
             >
        </LinearLayout>
    </ScrollView>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="bottom"
        android:orientation="horizontal" >

        <EditText
            android:id="@+id/edit_chat"
            android:layout_width="wrap_content"
            android:layout_height="45dp"
            android:layout_gravity="left|center_vertical"
            android:layout_weight="5" />

        <Button
            android:id="@+id/chat_submit"
            android:layout_width="wrap_content"
            android:layout_height="45dp"
            android:layout_gravity="right|center_vertical"
            android:onClick="onSubmit"
            android:text="OK" />
    </LinearLayout>

</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-06-10T23:38:02+00:00Added an answer on June 10, 2026 at 11:38 pm

    You can do it pragmatically like this, this is just an example. You may want to change your code based on that.

        LinearLayout linearLayout = (LinearLayout) findViewById(R.id.mylayout);
        TextView txt1 = new TextView(MyClass.this);
        LinearLayout.LayoutParams layoutParams =
                    (RelativeLayout.LayoutParams) txt1.getLayoutParams();
        layoutParams.addRule(LinearLayout.BOTTOM, 1);
        txt1.setLayoutParams(layoutParams);
        linearLayout.addView(txt1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to add two DataViews together to have one Dataview that can then
I can't access a element with its href. Like this example, i need add
I need to add some numbers / text, programmatically so it shows on top
I need to add a view to multiple views in app. I am running
I need a table GUI control that is able to quickly add and show
I need to add more views to a view for handling multiple webaddress and
I add 3 views for an application and they need to switch from 1-2-3.
I was able to add a timestamp (the question/problem below)... but now I'm having
I have a View to that I need to add some text. The used
In my Android Activity, I need to add a single View dynamically (at runtime),

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.