Android 9补丁背景不可见

Android 9补丁背景不可见,android,layout,nine-patch,Android,Layout,Nine Patch,我正在尝试使用一个9面片可绘制作为线性布局的背景 当我在xml中向布局添加视图时,我在Eclipse图形布局中可以很好地看到背景,但是当我启动应用程序时,背景是不可见的 以下是布局代码: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_conten

我正在尝试使用一个9面片可绘制作为线性布局的背景

当我在xml中向布局添加视图时,我在Eclipse图形布局中可以很好地看到背景,但是当我启动应用程序时,背景是不可见的

以下是布局代码:

<?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>
以下是布局背景9-patch可绘制:

将背景从9-patch更改为其他颜色。并通过代码运行它,而不使用它。这个新背景可见吗?对于我的第一个版本,您的9-patch可能在列表中。

请问您的9-patch的名称是什么?行动??请把它也放到问题中去。只有背景是看不见的吗?所有其他细节都可以吗?是的,只有操作弹出窗口是不可见的。我将操作弹出窗口添加到我的问题中。正如我提到的,如果我在xml上添加动作项,我会在图形布局中看到背景,但当我启动应用程序时,我不会。如果我涂上颜色,你的照片会隐藏在列表下面吗?不,它们不是空的。正如我所说,只有背景是不可见的。我看到了所有其他内容,没有背景看起来,子布局覆盖了整个父布局A,在它们的背景下,你看不到9-patch的图片。尝试关闭quickaction\u slider\u btn背景
<?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>
    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;
        }
     }
}
@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;
    }