From 5b2bcc270c832f8ab76b0243e43bdeaf52b2294d Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Wed, 19 Dec 2012 19:02:03 +0100 Subject: Use better aligned attributes in cache description This was already discussed in #82 but the solution seems not to have been fully satisfactory, especially when stars were present. This center aligns all the fields, use a relative layout to order them and use the same layout for fields with and without stars. --- main/res/layout/cache_item.xml | 35 --------------- main/res/layout/cache_layout.xml | 50 +++++++++++----------- .../cgeo/geocaching/ui/CacheDetailsCreator.java | 11 ++--- 3 files changed, 28 insertions(+), 68 deletions(-) delete mode 100644 main/res/layout/cache_item.xml diff --git a/main/res/layout/cache_item.xml b/main/res/layout/cache_item.xml deleted file mode 100644 index 6de416e..0000000 --- a/main/res/layout/cache_item.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - \ No newline at end of file diff --git a/main/res/layout/cache_layout.xml b/main/res/layout/cache_layout.xml index 59507eb..256026c 100644 --- a/main/res/layout/cache_layout.xml +++ b/main/res/layout/cache_layout.xml @@ -6,7 +6,7 @@ - - - - + android:text="@null" android:layout_centerVertical="true"/> + + + + \ No newline at end of file diff --git a/main/src/cgeo/geocaching/ui/CacheDetailsCreator.java b/main/src/cgeo/geocaching/ui/CacheDetailsCreator.java index 2a83ddc..9745d63 100644 --- a/main/src/cgeo/geocaching/ui/CacheDetailsCreator.java +++ b/main/src/cgeo/geocaching/ui/CacheDetailsCreator.java @@ -35,7 +35,7 @@ public final class CacheDetailsCreator { } public TextView add(final int nameId, final CharSequence value) { - final RelativeLayout layout = (RelativeLayout) activity.getLayoutInflater().inflate(R.layout.cache_item, null); + final RelativeLayout layout = (RelativeLayout) activity.getLayoutInflater().inflate(R.layout.cache_layout, null); final TextView nameView = (TextView) layout.findViewById(R.id.name); nameView.setText(res.getString(nameId)); lastValueView = (TextView) layout.findViewById(R.id.value); @@ -56,16 +56,15 @@ public final class CacheDetailsCreator { nameView.setText(activity.getResources().getString(nameId)); lastValueView.setText(String.format("%.1f", value) + ' ' + activity.getResources().getString(R.string.cache_rating_of) + " 5"); - layoutStars.addView(createStarImages(value), 1); + createStarImages(layoutStars, value); + layoutStars.setVisibility(View.VISIBLE); parentView.addView(layout); return layout; } - private LinearLayout createStarImages(final float value) { + private void createStarImages(final ViewGroup starsContainer, final float value) { final LayoutInflater inflater = LayoutInflater.from(activity); - final LinearLayout starsContainer = new LinearLayout(activity); - starsContainer.setOrientation(LinearLayout.HORIZONTAL); for (int i = 0; i < 5; i++) { ImageView star = (ImageView) inflater.inflate(R.layout.star, null); @@ -78,8 +77,6 @@ public final class CacheDetailsCreator { } starsContainer.addView(star); } - - return starsContainer; } public void addCacheState(cgCache cache) { -- cgit v1.1