Tag: android-layout

Color of TextView shows as white on a real device with ConstraintLayout

I have been trying my hands on ConstraintLayout and so far I have liked it a lot except now I have run into a peculiar problem. The same layout, if I design using a RelativeLayout displays the color of the contained TextViews as the default text color(greyish) but with ConstraintLayout, it shows white. This happens […]

How to read XML file in android

I want to read xml file which looks like the following … I have stored it in assets folder with <ImageList SpriteSheetName=”hh_gmw01″> <Image Name=”gmw01″ x=”0″ y=”0″ width=”1047″ height=”752″/> <Image Name=”hht1l01″ x=”388″ y=”269″ width=”34″ height=”36″/> <Image Name=”hht1l02″ x=”147″ y=”99″ width=”85″ height=”33″/> </ImageList> How do I get these values?

Android Canvas locking throws IllegalArgumentException

I am trying to implement my own custom SurfaceView that, when touched, draws a circle at the point where the user touched the screen. However, when I call mSurfaceHolder.lockCanvas() I get an exception. Something along the lines of an illegal argument whenever the canvas locks. Sample code is posted below. public class TapArea extends SurfaceView […]

Android: Overlapping two views (intentionally!)

just wondering is it possible to overlap two elements? This is an illustration of what im trying to achieve: Basically its a circle ImageButton, which center lies on the corner of a rectangle. How should I go about positioning it? Can I use RelativeLayout or something else?

Animation at the beginning of activity jumps

I am working on animating custom Views for my Android app. I have accomplished this via Property Animations and calling invalidate() on the View in the onAnimationUpdate() callback, as per https://developer.android.com/guide/topics/graphics/prop-animation.html: Depending on what property or object you are animating, you might need to call the invalidate() method on a View to force the screen […]

add layout as a view in Android

I have a pretty complex layout defined in xml file , now I want to add this layout as a view using addView or something else. As layout is pretty much complex , its pretty cumbersome process to write the code for layout and then add it as a view. So is there anyway to […]

How do you reduce space between floating editText hint and editText box in Android?

I have an EditText with a floating hint but I was wondering how I would reduce the space between the floating hint and the EditText box. Right now my UI looks like http://imgur.com/9hQzzx4 and I want to reduce the space between the “Title” floating hint and the EditText box. Here’s the code to my xml […]

What is <view/> XML tag in layouts

When reading source code of SnackBar from design library, I found this sort of XML layout : <view xmlns:android=”http://schemas.android.com/apk/res/android” class=”android.support.design.widget.Snackbar$SnackbarLayout” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_gravity=”bottom” style=”@style/Widget.Design.Snackbar” /> I never saw this sort of XML with only a <view/> tag (with lower V, so that’s not the View class). My first guess is that it works like the […]

GridLayout collapses on small display

I have LinearLayout with TextView, GridLayout and another TextView. It is displayed correctly on many modern phones and tablets but it utterly fails on small display like Nexus S. See following pictures. I tried to decrease font size, remove 9-patch background and even remove all margins. I could see just digit7 when there were some […]

most lightweight ViewGroup for containers

what is the ViewGroup you should use when needing a container e.g. for a fragmenttransaction? I am kind of between FrameLayout and LinearLayout from my feeling but I would like to make a decision on facts 😉

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.