加入收藏 | 设为首页 | 会员中心 | 我要投稿 我爱制作网_潮州站长网 (http://www.0768zz.com/)- 物联安全、建站、操作系统、云计算、数据迁移!
当前位置: 首页 > 教程 > 正文

Android 信息列表界面背景代码详解

发布时间:2021-11-21 16:06:37 所属栏目:教程 来源:互联网
导读:一、短信列表有短信菜单项时,界面背景绘制: 1 ConversationList.java: 2 ..packagesappsMmsreslayoutconversation_list_screen.xml: RelativeLayout xmlns:Android=http://schemas.android.com/apk/res/android android:layout_width=match_parent an

一、短信列表有短信菜单项时,界面背景绘制:
1 ConversationList.java:
 
2 ..packagesappsMmsreslayoutconversation_list_screen.xml:
<RelativeLayout  xmlns:Android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"  >
 
    <ListView android:id="@android:id/list"
        style="?android:attr/listViewWhiteStyle"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:drawSelectorOnTop="false"
        android:scrollbarStyle="insideOverlay"
        android:background="@android:color/white"
        android:cacheColorHint="@android:color/white"
        android:fadingEdgeLength="16dip" />
 
    <TextView android:id="@+id/empty"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="@string/no_conversations"
        android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
 
 
二、短信列表为空白时,界面背景绘制机制
 
1 ..frameworksbasepolicysrccomandroidinternalpolicyimplPhoneWindow.java:
 
public class PhoneWindow extends Window implements MenuBuilder.Callback {
    private void openPanel(PanelFeatureState st, KeyEvent event) {
 
            int backgroundResId;
            if (lp.width == ViewGroup.LayoutParams.MATCH_PARENT) {
                // If the contents is fill parent for the width, set the
                // corresponding background
                backgroundResId = st.fullBackground;
                width = MATCH_PARENT;
            } else {
                // Otherwise, set the normal panel background
                backgroundResId = st.background;
            }
            st.decorView.setWindowBackground(getContext().getResources().getDrawable(
                    backgroundResId));
        }
    }
 
 
    private final class DecorView extends FrameLayout implements RootViewSurfaceTaker {
        /* package */int mDefaultOpacity = PixelFormat.OPAQUE;
 
        public void setWindowBackground(Drawable drawable) {
            if (getBackground() != drawable) {
                setBackgroundDrawable(drawable);
                if (drawable != null) {
                    drawable.getPadding(mBackgroundPadding);
                } else {
                    mBackgroundPadding.setEmpty();
                }
                drawableChanged();
            }
        }
 
        @Override
        public void setBackgroundDrawable(Drawable d) {
            super.setBackgroundDrawable(d);
            if (getWindowToken() != null) {
                updateWindowResizeState();
            }
        }
    }
 
    private static final class DrawableFeatureState {
        void setStyle(Context context) {
            TypedArray a = context.obtainStyledAttributes(com.android.internal.R.styleable.Theme);
            background = a.getResourceId(
                    com.android.internal.R.styleable.Theme_panelBackground, 0);
            fullBackground = a.getResourceId(
                    com.android.internal.R.styleable.Theme_panelFullBackground, 0);
        }
    }
}
 
2 ..frameworksbasecoreresresvaluesThemes.xml:
        <item name="panelBackground">@android:drawable/menu_background</item>
        <item name="panelFullBackground">@android:drawable/menu_background_fill_parent_width</item>
 
3 ..frameworksbasecoreresresdrawable-hdpi:
        menu_background.9.png
        menu_background_fill_parent_width.9.png

(编辑:我爱制作网_潮州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读