GreenDroid总结

1.    theme,style
1.1.gd_attrs.xml里声明了很多引用,如

<attr name="gdActionBarBackground" format="reference" />

1.2.gd_themes.xml里声明了应用的theme,Theme.GDCatalog,

<style name="Theme.GDCatalog" parent="@style/Theme.GreenDroid.NoTitleBar">
	
		<item name="gdActionBarTitleColor">@android:color/white</item>
		<item name="gdActionBarBackground">@drawable/action_bar_background</item>
		<item name="gdActionBarDividerDrawable">@drawable/action_bar_divider</item>
		<item name="gdActionBarDividerWidth">2px</item>
		<item name="gdActionBarApplicationDrawable">@drawable/greendroid_application_logo</item>

	</style>


这里定义了此主题的属性,
<item name="gdActionBarBackground">@drawable/action_bar_background</item>
1.3.在应用的application的theme里应用上面的theme

    <application
        android:icon="@drawable/ic_gdcatalog"
        android:label="@string/app_name"
        android:theme="@style/Theme.GDCatalog"
        android:name=".CatalogApplication">


1.4在layout里应用主题里的某个属性,如应用上面的gdActionBarBackground,

<greendroid.widget.ActionBar
		android:id="@id/gd_action_bar"
		android:layout_height="@dimen/gd_action_bar_height"
		android:layout_width="fill_parent"
		android:background="?attr/gdActionBarBackground" />

2.InfoTabActivity

public class InfoTabActivity extends GDTabActivity {
设置layout:

  @Override
    public int createLayout() {
        return R.layout.info;
    }

R.layout.info:

<greendroid.widget.ActionBarHost
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:id="@id/gd_action_bar_host"
	android:layout_width="fill_parent"
	android:layout_height="fill_parent"
	android:orientation="vertical">

	<greendroid.widget.ActionBar
		android:id="@id/gd_action_bar"
		android:layout_height="@dimen/gd_action_bar_height"
		android:layout_width="fill_parent"
		android:background="?attr/gdActionBarBackground" />

	<FrameLayout
		android:id="@id/gd_action_bar_content_view"
		android:layout_height="0dp"
		android:layout_width="fill_parent"
		android:layout_weight="1">

		<TabHost
			android:id="@android:id/tabhost"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:paddingTop="5dp">

			<LinearLayout
				android:orientation="vertical"
				android:layout_width="fill_parent"
				android:layout_height="fill_parent">

				<LinearLayout
					android:layout_width="fill_parent"
					android:layout_height="wrap_content"
					android:orientation="vertical"
					android:paddingRight="20dp"
					android:paddingLeft="20dp"
					android:paddingTop="8dp"
					android:paddingBottom="8dp">

					<TextView
						android:layout_width="fill_parent"
						android:layout_height="wrap_content"
						android:gravity="center_horizontal"
						android:text="@string/more_info_on_greendroid"
						android:textColor="@android:color/white" />

					<TextView
						android:layout_width="fill_parent"
						android:layout_height="wrap_content"
						android:layout_marginTop="5dp"
						android:focusable="true"
						android:clickable="true"
						android:gravity="center_horizontal"
						android:paddingRight="20dp"
						android:paddingLeft="20dp"
						android:text="@string/app_url"
						android:textColor="@color/link"
						android:textStyle="bold"
						android:onClick="onAppUrlClicked" />

				</LinearLayout>

				<TabWidget
					android:id="@android:id/tabs"
					android:layout_width="fill_parent"
					android:layout_height="wrap_content"
					android:layout_marginLeft="-2dp"
					android:layout_marginRight="-2dp"
					android:background="@null" />

				<FrameLayout
					android:id="@android:id/tabcontent"
					android:layout_width="fill_parent"
					android:layout_height="0dip"
					android:layout_weight="1" />

			</LinearLayout>

		</TabHost>

	</FrameLayout>

</greendroid.widget.ActionBarHost>



你可能感兴趣的:(GreenDroid总结)