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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:49:16+00:00 2026-05-23T17:49:16+00:00

I have the following template in my android app. When I use the android:layout_MarginTop=20dip

  • 0

I have the following template in my android app. When I use the android:layout_MarginTop=”20dip” does work well, i can see the 20dip space at the top of the layout.

<LinearLayout
android:orientation="horizontal" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
style="@style/list_buttom_single"
xmlns:android="http://schemas.android.com/apk/res/android">

<ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="wrap_content"  />
<LinearLayout android:gravity="center_vertical" android:paddingLeft="10dip" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.0">
    <TextView android:text="Login / Register" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/title" style="@style/content_page_large_text" />
    <TextView android:text="sample text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/subtitle" android:visibility="visible" style="@style/content_page_small_text" />
</LinearLayout>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/itemCount" android:visibility="gone" style="@style/content_page_large_count_text" />
<ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/chevron" style="@style/list_buttom_chevron" />
</LinearLayout> 

However, when I try to do this programatically using LayoutInflater, i am loosing this 20dip space.

        View notesView = mInflater.inflate(R.layout.list_item_single, null);
    ((TextView) notesView.findViewById(R.id.title)).setText("Notes");
    ((TextView) notesView.findViewById(R.id.subtitle)).setText("102 notes");
    btnContainer.addView(notesView);

Why am I getting two different behavior for the “same” action, the only difference is that one is include uisng xml and the other one is using java.

Many thanks
T

  • 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-23T17:49:16+00:00Added an answer on May 23, 2026 at 5:49 pm

    Because layout parameters are only associated with view if you specify parent view. That’s why you should use another version of inflate():

    View notesView = mInflater.inflate(R.layout.list_item_single, btnContainer, false);
    ...
    btnContainer.addView(notesView);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: template <typename Provider> inline void use() { typedef Provider::Data<int>
I have the following template: <a href={{test_url}}>Test</a> But it doesn't work, instead the {{}}
I have the following template <h2>one</h2> <xsl:apply-templates select=one/> <h2>two</h2> <xsl:apply-templates select=two/> <h2>three</h2> <xsl:apply-templates select=three/>
I have the following template declaration: template <typename T> void IterTable(int& rIdx, std::vector<double>& rVarVector,
I have the following xsl template that I'm using to group my xsl. The
I have the following code: template <typename T> LuaCall& operator>>(T) { BOOST_STATIC_ASSERT(sizeof(T) == 0);
I have used the following template in my project: <DataTemplate x:Key=textBoxDataTemplate> <TextBox Name=textBox ToolTip={Binding
I have the following XSL template (I omitted the template for Organization, let me
I have the following pattern: template <int a, int b> class MyClass { public:
I have the following code: template <class T> struct pointer { operator pointer<const T>()

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.