设为首页 加入收藏

TOP

Android 信息列表界面背景代码分析
2014-11-24 03:14:29 来源: 作者: 【 】 浏览:2
Tags:Android 信息 界面 背景 代码 分析

一、短信列表有短信菜单项时,界面背景绘制:
1 ConversationList.java:


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" />


android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/no_conversations"
android:textAppearance=" android:attr/textAppearanceMedium" />



二、短信列表为空白时,界面背景绘制机制


1 ..\frameworks\base\policy\src\com\android\internal\policy\impl\PhoneWindow.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 ..\frameworks\base\core\res\res\values\Themes.xml:
@android:drawable/menu_background
@android:drawable/menu_background_fill_parent_width


3 ..\frameworks\base\core\res\res\drawable-hdpi:
menu_background.9.png
menu_background_fill_parent_width.9.png


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Linux 获取设备树源文件(DTS)里.. 下一篇shell脚本实现智能化查看功能

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·请问微信4.0版本xwec (2025-12-24 22:48:42)
·电脑NVIDIA的文件夹 (2025-12-24 22:48:40)
·如何看待微信新版本 (2025-12-24 22:48:37)
·C语言中如何将结构体 (2025-12-24 22:20:09)
·纯C语言结构体成员变 (2025-12-24 22:20:06)