Permalink
Browse files

new constructor and logic to better handle TabWidget target, addition…

…al layout tests
  • Loading branch information...
1 parent e0b40dc commit 2966920914fd228fd52b5ec1e719ef64b8250159 @jgilfelt committed Oct 2, 2011
View
@@ -3,9 +3,9 @@ Android ViewBadger
A simple way to "badge" any given Android view at runtime without having to cater for it in layout.
-![Demos](http://jeffgilfelt.com/viewbadger/badge1.png "Demos") 
-![ListAdapter](http://jeffgilfelt.com/viewbadger/badge2.png "ListAdapter") 
-![Layout Tests](http://jeffgilfelt.com/viewbadger/badge3.png "Layout Tests")
+![Demos](http://www.jeffgilfelt.com/viewbadger/badge1.png "Demos") 
+![ListAdapter](http://www.jeffgilfelt.com/viewbadger/badge2.png "ListAdapter") 
+![Layout Tests](http://www.jeffgilfelt.com/viewbadger/badge3.png "Layout Tests")
Note: If your aim is to replicate the iOS icon and TabBar badge UI for notifications, consider using Android UI conventions such as the number field of the [Notification](http://developer.android.com/reference/android/app/Notification.html "Notification") class rather than this method.
View
Binary file not shown.
View
@@ -4,130 +4,201 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent">
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
-
<LinearLayout
- android:orientation="horizontal"
+ android:orientation="vertical"
android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:padding="5dp">
-
- <com.readystatesoftware.viewbadger.BadgeView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="OK"
- android:id="@+id/badge"
- android:layout_gravity="center" />
+ android:layout_height="fill_parent">
- <TextView
+ <LinearLayout
+ android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:text="Defined in XML layout"
- android:layout_gravity="center"
- android:padding="5dp" />
+ android:padding="5dp">
- </LinearLayout>
+ <com.readystatesoftware.viewbadger.BadgeView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="OK"
+ android:id="@+id/badge"
+ android:layout_gravity="center" />
- <LinearLayout
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:padding="5dp">
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="Defined in XML layout"
+ android:layout_gravity="center"
+ android:padding="5dp" />
- <TextView
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="LinearLayout"
- android:layout_gravity="center"
- android:padding="5dp" />
-
- <ImageView
- android:layout_width="wrap_content"
- android:src="@drawable/icon"
+ </LinearLayout>
+
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:id="@+id/linear_target"
- android:layout_gravity="center" />
+ android:padding="5dp">
- </LinearLayout>
+ <TextView
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="LinearLayout Container"
+ android:layout_gravity="center"
+ android:padding="5dp" />
- <RelativeLayout
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:padding="5dp">
+ <ImageView
+ android:layout_width="wrap_content"
+ android:src="@drawable/icon"
+ android:layout_height="wrap_content"
+ android:id="@+id/linear_target"
+ android:layout_gravity="center" />
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:text="RelativeLayout"
- android:layout_gravity="center"
- android:id="@+id/relative_label"
- android:padding="5dp" />
-
- <ImageView
- android:layout_width="wrap_content"
- android:src="@drawable/icon"
+ </LinearLayout>
+
+ <RelativeLayout
+ android:orientation="horizontal"
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:layout_toRightOf="@id/relative_label"
- android:id="@+id/relative_target"
- android:layout_gravity="center" />
+ android:padding="5dp">
- </RelativeLayout>
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:text="RelativeLayout Container"
+ android:layout_gravity="center"
+ android:id="@+id/relative_label"
+ android:padding="5dp" />
- <FrameLayout
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:padding="5dp">
+ <ImageView
+ android:layout_width="wrap_content"
+ android:src="@drawable/icon"
+ android:layout_height="wrap_content"
+ android:layout_toRightOf="@id/relative_label"
+ android:id="@+id/relative_target"
+ android:layout_gravity="center" />
- <ImageView
- android:layout_width="wrap_content"
- android:src="@drawable/icon"
- android:layout_height="wrap_content"
- android:id="@+id/frame_target"
- android:layout_gravity="center" />
+ </RelativeLayout>
- <TextView
- android:layout_width="wrap_content"
+ <FrameLayout
+ android:orientation="horizontal"
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:text="FrameLayout"
- android:layout_gravity="center"
- android:padding="5dp" />
-
- </FrameLayout>
-
- <TableLayout
- android:id="@+id/tableLayout1"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- <TableRow
- android:id="@+id/tableRow1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content">
+ android:padding="5dp">
<ImageView
android:layout_width="wrap_content"
android:src="@drawable/icon"
android:layout_height="wrap_content"
- android:id="@+id/table_target"
+ android:id="@+id/frame_target"
android:layout_gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="TableLayout"
+ android:text="FrameLayout Container"
+ android:layout_gravity="center"
+ android:padding="5dp" />
+
+ </FrameLayout>
+
+ <TableLayout
+ android:id="@+id/tableLayout1"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+
+ <TableRow
+ android:id="@+id/tableRow1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:src="@drawable/icon"
+ android:layout_height="wrap_content"
+ android:id="@+id/table_target"
+ android:layout_gravity="center" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="TableLayout Container"
+ android:layout_gravity="center"
+ android:padding="5dp" />
+
+ </TableRow>
+ </TableLayout>
+
+ <!-- ViewGroup target tests -->
+
+ <LinearLayout
+ android:id="@+id/linear_group_target"
+ android:orientation="horizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="100dp"
+ android:padding="5dp"
+ android:background="#3366FF">
+
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="LinearLayout Target"
android:layout_gravity="center"
android:padding="5dp" />
- </TableRow>
- </TableLayout>
+ </LinearLayout>
-</LinearLayout>
+ <RelativeLayout
+ android:id="@+id/relative_group_target"
+ android:layout_width="fill_parent"
+ android:layout_height="100dp"
+ android:padding="5dp"
+ android:background="#33CCFF">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true"
+ android:text="RelativeLayout Target"
+ android:layout_gravity="center"
+ android:padding="5dp" />
+
+ </RelativeLayout>
+
+ <FrameLayout
+ android:id="@+id/frame_group_target"
+ android:layout_width="fill_parent"
+ android:layout_height="100dp"
+ android:padding="5dp"
+ android:background="#33FFCC">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="FrameLayout Target"
+ android:layout_gravity="center"
+ android:padding="5dp" />
+
+ </FrameLayout>
+
+ <TableLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+
+ <TableRow
+ android:id="@+id/tablerow_group_target"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:background="#33FF66">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="TableRow Target"
+ android:layout_gravity="center"
+ android:padding="5dp" />
+
+ </TableRow>
+ </TableLayout>
+
+ </LinearLayout>
</ScrollView>
Oops, something went wrong.

0 comments on commit 2966920

Please sign in to comment.