主要是修改dialog的资源,也就是替换图片,或者还一个主题。主要系统的对话框,Ok
下面是修改之前的系统的对话框的样式:
在桌面长按出现的对话框,或者在settings中设置动画的对话框
修改之后的对话框的样式如下:
系统对话框的样式和资源文件都在framework中,足要自己准备图片资源,需要的图片的位置在:
frameworks/base/core/res/res/drawable-mdpi中,需要替换的资源为:
popup_top_dark.9.png 对话框上面的背景图片,popup_bottom_dark.9.png对话框下面的背景图片 popup_center_bright.9.png对话框中间的图片文件,有的对话框在下面有button(1 2 3),在下面的配置文件中标红的是对button所做的修改,需要准备对应的buttong的资源,每个button的资源需要对应的准备两套图片,一张是正常显示的,一张是按下去之后的效果,left button: popup_button_left.9.png popup_button_left_pressed.9.png middle button : popup_button_between.9.png popup_button_between_pressed.9.png right button: popup_button_right.9.png popup_button_right_pressed.9.png 图片资源也放在 frameworks/base/core/res/res/drawable-mdpi中,还需要写对应的button的配置文件 放在 frameworks/base/core/res/res/drawable中,popup_botton_left.xml :
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/popup_button_left_pressed" />
<item
android:drawable="@drawable/popup_button_left" />
</selector>
对应的 popup_botton_between.xml popup_botton_right.xml 内容格式和上面的一样。
修改之后的系统对话框的配置文件在 frameworks/base/core/res/res/layout/alert_dialog.xml:
<com.android.internal.widget.WeightedLinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/parentPanel" android:layout_width="450dip" android:layout_height="wrap_content" android:orientation="vertical"> <LinearLayout android:id="@+id/topPanel" android:layout_width="450dip" android:layout_height="wrap_content" android:minHeight="48dip" android:orientation="vertical"> <LinearLayout android:id="@+id/title_template" android:layout_width="450dip" android:layout_height="wrap_content" android:minHeight="48dip" android:orientation="horizontal" android:gravity="center_vertical" android:layout_marginTop="6dip" android:layout_marginBottom="9dip" android:layout_marginLeft="10dip" android:layout_marginRight="10dip"> <ImageView android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" android:paddingTop="6dip" android:paddingRight="10dip" android:src="@drawable/ic_dialog_info" /> <com.android.internal.widget.DialogTitle android:id="@+id/alertTitle" style="?android:attr/textAppearanceLarge" android:singleLine="true" android:ellipsize="end" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> <ImageView android:id="@+id/titleDivider" android:layout_width="match_parent" android:layout_height="1dip" android:visibility="gone" android:scaleType="fitXY" android:gravity="fill_horizontal" android:src="@android:drawable/divider_horizontal_dark" /> <!-- If the client uses a customTitle, it will be added here. --> </LinearLayout> <LinearLayout android:id="@+id/contentPanel" android:layout_width="450dip" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <ScrollView android:id="@+id/scrollView" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="2dip" android:paddingBottom="12dip" android:paddingLeft="14dip" android:paddingRight="10dip" android:overScrollMode="ifContentScrolls"> <TextView android:id="@+id/message" style="?android:attr/textAppearanceMediumInverse" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="5dip" /> </ScrollView> </LinearLayout> <FrameLayout android:id="@+id/customPanel" android:layout_width="450dip" android:layout_height="wrap_content" android:layout_weight="1"> <FrameLayout android:id="@+android:id/custom" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="5dip" android:paddingBottom="5dip" /> </FrameLayout> <LinearLayout android:id="@+id/buttonPanel" android:layout_width="450dip" android:layout_height="54dip" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingTop="0dip" android:paddingLeft="0dip" android:paddingRight="0dip" android:useLargestChild="true"> <LinearLayout android:id="@+id/leftSpacer" android:layout_weight="0" android:layout_width="0dip" android:layout_height="wrap_content" android:orientation="horizontal" android:visibility="gone" /> <Button android:id="@+id/button1" android:layout_width="0dip" android:layout_gravity="left" android:layout_weight="1" android:maxLines="2" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:background="@drawable/popup_botton_left" /> <Button android:id="@+id/button3" android:layout_width="0dip" android:layout_gravity="center_horizontal" android:layout_weight="1" android:maxLines="2" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:background="@drawable/popup_botton_between" /> <Button android:id="@+id/button2" android:layout_width="0dip" android:layout_gravity="right" android:layout_weight="1" android:maxLines="2" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:background="@drawable/popup_botton_right" /> <LinearLayout android:id="@+id/rightSpacer" android:layout_width="0dip" android:layout_weight="0" android:layout_height="wrap_content" android:orientation="horizontal" android:visibility="gone" /> </LinearLayout> </LinearLayout> </com.android.internal.widget.WeightedLinearLayout>