Android平台定义的主题样式:
android:theme="@android:style/Theme.Dialog"
•android:theme="@android:style/Theme.NoTitleBar"
•android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
•android:theme="@android:style/Theme.Light"
•android:theme="@android:style/Theme.Light.NoTitleBar"
•android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"
•android:theme="@android:style/Theme.Black"
•android:theme="@android:style/Theme.Black.NoTitleBar"
•android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
•android:theme="@android:style/Theme.Wallpaper"
•android:theme="@android:style/Theme.Wallpaper.NoTitleBar"
•android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"
•android:theme="@android:style/Translucent" 半透明效果
•android:theme="@android:style/Theme.Translucent.NoTitleBar"
•android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
•android:theme="@android:style/Theme.Panel"
Android平台定义了三种字体大小:
"?android:attr/textAppearanceLarge"
"?android:attr/textAppearanceMedium"
"?android:attr/textAppearanceSmall"
Android字体颜色:
android:textColor="?android:attr/textColorPrimary"
android:textColor="?android:attr/textColorSecondary"
android:textColor="?android:attr/textColorTertiary"
android:textColor="?android:attr/textColorPrimaryInverse"
android:textColor="?android:attr/textColorSecondaryInvers
Android的ProgressBar样式:
style="?android:attr/progressBarStyleHorizont
style="?android:attr/progressBarStyleLarge"
style="?android:attr/progressBarStyleSmall"
style="?android:attr/progressBarStyleSmallTit
分隔符
横向: <View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
纵向: <View android:layout_width="1dip"
android:layout_height="fill_parent"
android:background="?android:attr/listDivider" /
CheckBox样式
style="?android:attr/starStyle"
类似标题栏效果的TextView
style="?android:attr/listSeparatorTextViewSty
其它有用的样式
android:layout_height="?android:attr/listPreferredItemHeight"
android:paddingRight="?android:attr/scrollbarSize"
style="?android:attr/windowTitleBackgroundSty
style="?android:attr/windowTitleStyle"
android:layout_height="?android:attr/windowTitleSize"
android:background="?android:attr/windowBackground"
修改Activity的标题栏样式
如在styles.xml中增加
<resources>
</resources>
————————————————————————————————————————————————————————
自定义一个简单的dialog
在style文件中定义一个样式:
<style name="MyDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowBackground">@drawable/title_background</item>
<item name="android:windowNoTitle">true</item>
</style>
xml文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300dip"
android:layout_height="180dip"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登陆界面"
android:textSize="24sp" />
<LinearLayout
android:layout_width="300dip"
android:layout_height="80dip"
android:background="#ffc8c8c8"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="请输入密码"
android:textColor="#ff000000" />
<EditText
android:id="@+id/et_normal_entry_pwd"
android:layout_width="300dip"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="300dip"
android:layout_height="50dip"
android:layout_marginTop="10dip"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="@+id/bt_normal_dialog_ok"
android:layout_width="140dip"
android:layout_height="40dip"
android:background="@drawable/button_selector"
android:text="确定" />
<Button
android:id="@+id/bt_normal_dialog_cancle"
android:layout_width="140dip"
android:layout_height="40dip"
android:layout_marginLeft="5dip"
android:background="@drawable/button_selector"
android:text="取消" />
</LinearLayout>
</LinearLayout>
程序中代码如下:
dialog = new Dialog(this, R.style.MyDialog);
dialog.setCancelable(false);
//dialog.setContentView(R.layout.first_entry_dialog);
View view = View.inflate(this, R.layout.normal_entry_dialog, null);
et_pwd = (EditText) view.findViewById(R.id.et_normal_entry_pwd);
Button bt_normal_ok = (Button) view.findViewById(R.id.bt_normal_dialog_ok);
Button bt_normal_cancle = (Button) view.findViewById(R.id.bt_normal_dialog_cancle);
bt_normal_ok.setOnClickListener(this);
bt_normal_cancle.setOnClickListener(this);
dialog.setContentView(view);
dialog.show();
运行效果为