1

So, I really want to try and put numbers near my ImageButtons (kinda like the iPhone badge notifications) to tell the user how many new items are in that directory.

One way I was thinking of doing this was to put an icon above my Button and then put a TextView that I would edit to update the number and hide when there were no new items.

Unfortunately, I can't figure out how to put things on top of one another in the layout page. :(

4 Answers 4

1

Try this:

Create a FrameLayout that contains the Button and the TextView (in that order). Then the TextView will end up on top of your button. Just use layout parameters supported by the FrameLayout to adjust the position of the TextView until you are happy.

Or you could replace the RelativeLayout that you are using now with a FrameLayout, but then you probably need to make sure that all other views in that layout still are placed correctly. If you go with the first suggestion you only need to worry about the button and the text view.

1

Try using the frameLayout http://developer.android.com/reference/android/widget/FrameLayout.html

1

you have to use FrameLayout to put one item over another .

1

Use RelativeLayout and align both things to the same parent?

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
    <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" android:layout_alignParentTop="true"></TextView>
    <ImageButton android:src="@drawable/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageButton1"></ImageButton>
</RelativeLayout>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.