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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:28:30+00:00 2026-06-13T18:28:30+00:00

Here is my code: //define tablerows. each table row has max 3 buttons LinearLayout

  • 0

Here is my code:

 //define tablerows. each table row has max 3 buttons
 LinearLayout llRow1 = (LinearLayout)findViewById(R.id.llRow1); llRow1.removeAllViews();

   float scale = getResources().getDisplayMetrics().density;
   int padding_5dp = (int) (5 * scale + 0.5f);

//Define FrameLayout
       FrameLayout flTmp = new FrameLayout(this);
       LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT, 1f);
       lp.setMargins(0, 0, padding_5dp, padding_5dp);
       flTmp.setLayoutParams(lp);

//Add dynamically TextView
TextView tvTmp = new TextView(this);
tvTmp.setText("Test");
LinearLayout.LayoutParams tvPara=new LinearLayout.LayoutParams(
                            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT );
tvPara.gravity = Gravity.BOTTOM | Gravity.LEFT;
tvPara.setMargins(padding_5dp, 0, 0, 0);
tvTmp.setLayoutParams(tvPara);

//Add dynamically Buttons for juice
    ImageButton btnTmp = new ImageButton(this);

[...]

//Add Button and TextView to FrameLayout
    flTmp.addView(btnTmp);
    flTmp.addView(tvTmp);

llRow1.addView(flTmp);

What i try to do is create an imagebutton dynamically with a textview description like following xml code:

<FrameLayout>
<ImageButton android:background="@null" android:id="@+id/button_x" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="fitXY" android:src="@drawable/button_graphic"></ImageButton>    
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:clickable="false" android:text="TEST TEST"></TextView>
</FrameLayout>

works fine with my code, but the textview ignores margin and gravity parameters.
its located on upper left corner without margins.

Any hint?

  • 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-13T18:28:31+00:00Added an answer on June 13, 2026 at 6:28 pm

    The LayoutParams you use need to be of the type of parent that the child is contained in. You’re FrameLayout contains the TextView, but you’re assigning a LinearLayout.LayoutParams reference to it. Make it a FrameLayout.LayoutParams or change to a LinearLayout. If I had to guess, it’s silently catching this error and just ignoring it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the code I use to define my array, this code is above
Here is my code: #include <stdio.h> #include <string.h> #include <windows.h> #include <tchar.h> #define MAX_KEY_LENGTH
Here is some C++ code I'm playing around with: #include <iostream> #include <vector> #define
I'm trying to figure out why callParent isn't working. Here's some code: Ext.define('AM.ArView', {
Here's my code: (define step1_list1 '(1 3 (5 7) 9)) (car (cdr (cdr (step1_list1))))
Here is the code: (define test1DataA '((a a) (b b) (c c) (d d)
I have a problem displaying my Ext.list component. Here is my code: Ext.define(iphone.view.customers.List, {
so here is the code: (define (time-prime-test n) (newline) (display n) (start-prime-test n (runtime)))
Here is my test code: #define print(A) cout << #A << = << A
I want to define just one row in my table. To this row, I

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.