Profile

Cover photo
Gregory Meiste
44 followers|107,875 views
AboutPostsPhotosYouTube

Stream

Gregory Meiste

Shared publicly  - 
 
This looks useful! I'll have to remember this the next time I'm creating Android layouts.
 
Percentage Based Dimensions and Margins with the Percent Support Library
Pro-tip by +Joanna Smith

There are a lot of options to help you position your Views just right. But adding a LinearLayout to your beautiful RelativeLayout just to gain access to layout_weight for that perfect positioning is ridiculous. And we hear you on that. Which is why Android introduced the new Percent Support Library (https://goo.gl/XTOD5G). Its PercentFrameLayout and PercentRelativeLayout provide an easy way to specify View dimensions and margins in terms of a percentage of the overall size.

That means if you want a view to take up exactly 50% of the available width and height, you’d use a layout such as
<android.support.percent.PercentRelativeLayout>
 <ImageView
  android:id=”@+id/centered_image”
  android:layout_gravity=”center”
  app:layout_widthPercent="50%"
  app:layout_heightPercent="50%" />
 <TextView
  android:id=”@+id/caption”
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_below=”@id/centered_image”
  android:layout_gravity=”center_horizontal”
  app:layout_marginStartPercent=”25%”
  app:layout_marginEndPercent=”25%” />
</android.support.percent.PercentRelativeLayout>

Note that we use layout_marginStartPercent/EndPercent to set a margin based on a percentage of the total width.

Fun fact: if the percentage you set is more of a guideline than hard limit, you can also set layout_width/height=”wrap_content” in addition to layout_widthPercent/heightPercent and Views larger than the allowed percentage value will instead be resized using wrap_content rules.

So check out the Percent library today and use this efficient layout to #BuildBetterApps  
35 comments on original post
1
Add a comment...

Gregory Meiste

Shared publicly  - 
 
New release now available! Get it while it's hot!
 
On January 16, 2012, development began on Pick The Winner. Later that year, on July 18, 2012, we published Pick The Winner 1.0 on +Google Play. Almost exactly two years later, we're pleased to announce Pick The Winner 3.4.0 (our 14th release)!

Changes in this release include:
- Questions screen will now continue to show current race after the #NASCAR  race has started to make it easier for players to check how they answered questions while the race is in progress.
- Now can swipe between race detail screens (only on #Android  4.1 and later).
- Switch to Android standardized pull-to-refresh UI.
- Many improvements under the hood.
- Fixed rare app crashes seen by some users.

The minimum requirement is +Android 2.3.3 or later. Please note that this release is the last planned release that will support Android 2.3 and 3.x. Barring any bugs, our next release will only support Android 4.x or later. More details to follow.

Pick The Winner 3.4.0 will be available on Google Play shortly. Instead of answering questions this week (it's an off week), please download and enjoy the new release!

#androidapps   #androidgames  
Pick The Winner is an Android game that allows NASCAR fans from around the ...
1
Add a comment...

Gregory Meiste

Shared publicly  - 
 
Stumbled across this article today. It finally explained the proper use of Android's LayoutInflater to me.

#androiddev  
Using LayoutInflater improperly can lead to undiscovered issues in your Android application, or force you to use workarounds that are difficult to maintain.
1
Add a comment...

Gregory Meiste

Shared publicly  - 
 
Fellow Android Developers! I have a StackOverflow question for you. Your help is appreciated. :-)

#androiddev   #android  
1
Add a comment...

Gregory Meiste

Shared publicly  - 
 
The 2014 update for Pick The Winner is here! Get it while it's hot!
 
Happy New Year! Are you ready for the upcoming #NASCAR  season? We are! The Sprint Unlimited is only a month away. To celebrate, today we're excited to announce Pick The Winner version 3.2.0 for #Android . It is a big update: 224 changed files with 3,713 lines of additions and 5,340 deletions! Here is what is new:

- Multi-device support! Now changes you make to your account (answer submissions, player name, friends) are immediately reflected on all your devices. This feature is not available to everyone right away and is rolling out gradually to all players. To speed it along, after upgrading to version 3.2.0, you can sign into your account again on all your devices and the app will take care of the rest.

- Tablet layout for Questions tab. Players with 10" tablets will now have a multi-pane screen for questions, making better use of the available screen size.

Smaller changes include:
- 2014 schedule included by default.
- Add track’s city and state to Race Details screen.
- Improve data usage of widget
- Support for Android 4.3 and 4.4
- Added link to our Google+ page
- Several minor bug fixes

Minimum supported version is +Android 2.3.3 or later. It will be available on +Google Play shortly.

Not yet a player? Think you know NASCAR? Download the "Pick The Winner" app today and prove it!

#androidapps   #androidgames  
Pick The Winner is an Android game that allows NASCAR fans from around the ...
1
Add a comment...

Gregory Meiste

Shared publicly  - 
 
Cool use of +Google Glass#NASCAR  
A NASCAR first – a pit stop through Google Glass!
2
Vince Meiste's profile photo
 
Cool, but makes me dizzy!
Add a comment...
Have him in circles
44 people
Brian Stewart's profile photo
Jason Ritchie's profile photo
Melinda Hileman's profile photo
Misc IT's profile photo
Amy Triggs's profile photo
Scott Quick's profile photo
Mike Corrigan's profile photo
Anna Smith's profile photo
nimra hussain's profile photo

Gregory Meiste

Discussion  - 
 
Looks great on my Moto 360! Much better than other watch faces I've seen/used. One thing that does look strange is the notification overlay when the screen is dimmed. The message text is placed directly on top of the watch face. I prefer how the "minimal" watch face handles this case. It adds a transparent background to the notification, giving the appearance that the notification is on top of the watch. It's subtile, but to me really helps the readibility of the notification text.

Other than that, I'm very pleased. Kudos!
2
1
Carlos Jorge Guerra's profile photo
Add a comment...

Gregory Meiste

Shared publicly  - 
 
Sweet! Can't wait to give this a try!
 
Call me maybe? Free voice calls via Hangouts, now available on Android, iOS and the web → http://goo.gl/Cj0aNx
1
Mike Creuzer's profile photo
 
This is awesome. I think your post just saved me a bit of money because I have a limited pre-paid plan and pay a fortune for internet at home.
Add a comment...

Gregory Meiste

General Discussion  - 
 
Fellow Android Developers! I have a StackOverflow question for you. Your help is appreciated. :-)
7
2
Paul Jones's profile photo임명훈's profile photo
Add a comment...

Gregory Meiste

Shared publicly  - 
 
Can you spot the defect before reading the answer?
 
Writing correct concurrent Java code is hard

See if you can spot what's wrong with this code I came across today, simplified here*:

class Foo {
Boolean myFlag = Boolean.valueOf(false);

void foo() {
  synchronized(myFlag) {
    ...
    myFlag = Boolean.valueOf(true);
  }
}

void bar() {
  synchronized(myFlag) {
    myFlag = Boolean.valueOf(false);
  }
}

Let me first provide a brief explanation of how the synchronized statement works in Java. Every Object has an intrinsic lock associated with it. The synchronized statement obtains the lock associated with the object, runs the code inside the block, then releases the lock.

In this case, the synchronized statement obtains the lock associated with the object in the "myFlag" field. The programmer has recognized that you can't lock over a primitive type (boolean), so has opted to use Boolean (which is a subclass of Object).

There are two things wrong in this example:
1) the value of the "myFlag" field is reassigned. In this case, it has one of two values: Boolean.TRUE and Boolean.FALSE.
2) if any code running in any thread also locks over either of these easily accessible values, the code running from this class is affected.

Three rules to prevent this mistake in your own Java code:
1) If possible, use synchronized methods instead of synchronized statements (they're simpler)
2) Only lock over fields marked as final, or the "this" object.
3) Create separate lock objects for fields that need this block, and in your source file, write a comment stating that as a contract. For example:
private final Object myFlagLock = new Object();
private boolean myFlag = false; // must synchronize on "myFlagLock".

In this case, an AtomicBoolean would work quitenicely, too:
private final AtomicBoolean myFlag = new AtomicBoolean(false);
synchronized(myFlag) {
   myFlag.set(true);
   ...
}

I've noticed that IntelliJ provides an inspection for this simple mistake. I can't recommend IntelliJ enough.

Read more about the synchronized statement/block here:
http://docs.oracle.com/javase/tutorial/essential/concurrency/locksync.html

Get the fantastic "Java Concurrency in Practice" book by +Joshua Bloch and others:
http://amzn.com/0321349601

* Full code was from the Pebble SDK examples, found here: http://goo.gl/CDxPMA

#java   #concurrency  
1
Kathleen McCoy's profile photo
 
Uhm, no. I don't see the error. But that's just me. 
Add a comment...

Gregory Meiste

Shared publicly  - 
 
Great site for looking up gradle syntax for your Android project dependencies.
Gradle, please. dependencies { // Google Play Services compile 'com.google.android.gms:play-services:' // Support Libraries compile 'com.android.support:support-v4:' compile 'com.android.support:appcompat-v7:' compile 'com.android.support:gridlayout-v7:' compile ...
1
Add a comment...

Gregory Meiste

Shared publicly  - 
 
This is really cool! Thanks +Richard Childress Racing for posting.
Ride along with Brian Scott as the Nationwide Series drafts during preseason thunder testing at Daytona International Speedway.
1
Add a comment...
People
Have him in circles
44 people
Brian Stewart's profile photo
Jason Ritchie's profile photo
Melinda Hileman's profile photo
Misc IT's profile photo
Amy Triggs's profile photo
Scott Quick's profile photo
Mike Corrigan's profile photo
Anna Smith's profile photo
nimra hussain's profile photo
Links
Basic Information
Gender
Male