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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:18:12+00:00 2026-05-29T04:18:12+00:00

I’m trying to use a 9-patch drawable as the background of a LinearLayout. when

  • 0

I’m trying to use a 9-patch drawable as the background of a LinearLayout.

when i add views to the layout in the xml, I see the background just fine in Eclipse graphical layout, but when I launch the app, the background is invisible.

here’s the layout code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<ImageView
    android:id="@+id/arrow_up"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/quickaction_arrow_up" />

<ImageView
    android:id="@+id/arrow_left"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:src="@drawable/quickaction_arrow_left" />



    <LinearLayout
        android:id="@+id/tracks"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/arrow_up"
        android:layout_toRightOf="@id/arrow_left"
        android:layout_centerVertical="true"
        android:padding="5dp"
        android:background="@drawable/action_popup"
        android:orientation="vertical" >
        <LinearLayout android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="horizontal">
             <include layout="@layout/action_item" android:id="@+id/item1"/>
             <include layout="@layout/action_item" android:id="@+id/item2"/>
        </LinearLayout>    

    </LinearLayout>

   <ImageView
    android:id="@+id/arrow_right"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_toRightOf="@id/tracks"
    android:src="@drawable/quickaction_arrow_right" />


<ImageView
    android:id="@+id/arrow_down"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/tracks"
    android:src="@drawable/quickaction_arrow_down" />

</RelativeLayout>

and here the code for action_item.xml:

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="65dp"
android:layout_height="100dp"
android:gravity="center"
android:clickable="true"
android:padding="5dp"
android:background="@drawable/quickaction_slider_btn">

<ImageView
    android:id="@+id/iv_icon" 
    android:layout_width="fill_parent" 
    android:layout_height="0dp"
    android:scaleType="fitXY"
    android:layout_weight="4"/>

<TextView 
    android:id="@+id/tv_title"
    android:layout_width="fill_parent" 
    android:layout_height="0dp"
    android:layout_weight="2"
    android:gravity="center"
    android:ellipsize="end"
    android:textSize="12sp"
    android:textColor="#666"/>

</LinearLayout>

Edit:

code snippet where I adding to the layout:

    protected void createActionList() {
        WindowManager windowManager = (WindowManager)
        m_context.getSystemService(Context.WINDOW_SERVICE);
        final int screenWidth = windowManager.getDefaultDisplay().getWidth();

        final int numItems = mActionItemList.size();

        View view;
        LinearLayout parent = null;
        boolean needNewRow = true;

        for( int i = 0; i < numItems; i++ ) {

            if( i % m_numOfColumns == 0 && m_numOfColumns > 0 ) {
                needNewRow = true;
            }

            if( needNewRow ) {
                parent = new LinearLayout( m_context );
                LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT );
                parent.setOrientation(LinearLayout.HORIZONTAL);
                params.weight = 1;
                parent.setLayoutParams( params );
                mTrack.addView( parent);
        }

        view = mAdapter.getView( i, null, parent );
        parent.addView(view);
        parent.measure( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT );
          int padding = mTrack.getPaddingLeft() + mTrack.getPaddingRight();
        int parentWidth = parent.getMeasuredWidth() + padding;
        int childWidth = parentWidth / parent.getChildCount();

        needNewRow = false;
        if( parentWidth + childWidth > screenWidth ) {
            m_numOfColumns = -1;
            needNewRow = true;
        }
     }
}

and code of the mAdapter.getView:

@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ActionItem action = (ActionItem)getItem(position);

        String title    = action.getTitle();
        Drawable icon   = action.getIcon();

        View container  = (View) inflater.inflate(R.layout.action_item, parent, false);

        ImageView img   = (ImageView) container.findViewById(R.id.iv_icon);
        TextView text   = (TextView) container.findViewById(R.id.tv_title);

        if (icon != null) { 
            img.setImageDrawable(icon);
        } else {
            img.setVisibility(View.GONE);
        }

        if (title != null) {
            text.setText(title);
        } else {
            text.setVisibility(View.GONE);
        }

        final int pos =  mChildPos++;
        final int actionId  = action.getActionId();

        container.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mItemClickListener != null) {
                    mItemClickListener.onItemClick(MyQuickAction.this, pos, actionId);
                }

                if (!getActionItem(pos).isSticky()) {  
                    mDidAction = true;

                    //workaround for transparent background bug
                    //thx to Roman Wozniak <roman.wozniak@gmail.com>
                    v.post(new Runnable() {
                        @Override
                        public void run() {
                            dismiss();
                        }
                    });
                }
            }
        });

        container.setFocusable(true);
        container.setClickable(true);
        return container;
    }

here’s the layout background 9-patch drawable:
action_popup

  • 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-29T04:18:13+00:00Added an answer on May 29, 2026 at 4:18 am

    Change the background from 9-patch to some extra color. And run it through code and without it. Is this new background visible? For my first version is that your 9-patch is probably under the list.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post

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.