Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8674667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:45:49+00:00 2026-06-12T19:45:49+00:00

Something very strange is going on with a custom view containing a TextView .

  • 0

Something very strange is going on with a custom view containing a TextView. Roughly speaking, (relevant code below), I have a custom view (subclass of FrameLayout), which inflates some xml and adds the resulting View as a child. The inflated view contains a TextView, referred to below as “the label”. Also possibly relevant (in case you’re not going to look at the code) is that the custom view is added as a child to a MapView.

The following really weird stuff happens:

  • Do nothing: label is not visible, parent looks fine. Interestingly, the parent view is clearly taking the label’s width into account (with the label visibility set to GONE the parent view is much narrower). In design mode the label is visible.
  • Touch the parent view: Label briefly becomes visible, then disappears. Holding your finger on it keeps the label visible until you end the touch.
  • Call this.setPressed(true), this of course being the parent view, from the parent view’s constructor: Label becomes visible, and stays that way until the parent view is touched, after which behavior reverts to “normal”.

Here’s the relevant code. By way of context, we’re sticking a balloon on a map when you touch the map, which should contain something along the lines of “Tap to choose this location”. There are some other views in the balloon, but their visibility is set to GONE initially, and the code to fill them in and show them is disabled. There are no map overlays involved, just attaching the view directly to the map with MODE_MAP to stick it to a single location.

From the custom view, BalloonView.java. Nothing else in this class touches the layout/view methods.

public BalloonView(Context context) {
    super(context);

    if(!isInEditMode()){ // RoboGuice doesn't like edit mode
        RoboGuice.getInjector(context).injectMembersWithoutViews(this);
    }

    LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    // We're *not* attaching the view with it's default layout params.
    View v = inflater.inflate(R.layout.balloon_view, this, false); 
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    params.gravity = Gravity.NO_GRAVITY;

    addView(v,params);

    label = (TextView) v.findViewById(R.id.label);
    addressContainer = v.findViewById(R.id.addressContainer);
    address1 = (TextView)findViewById(R.id.address1);
    address2 = (TextView) findViewById(R.id.address2);

    // makes label visible initially
    // setPressed(true);

}

    // This is the constructor that we actually call, in case it matters...  
public BalloonView(Context context, OnClickListener onClick) {
    this(context);
    setOnClickListener(onClick);
}

balloon_view.xml

    <TextView
        android:id="@+id/label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="6dip"
        android:layout_marginLeft="6dip"
        android:layout_marginRight="6dip"
        android:layout_marginTop="6dip" 
        android:text="@string/map_balloon_label"
        android:enabled="true"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <LinearLayout
        android:id="@+id/addressContainer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="6dip"
        android:layout_marginLeft="8dip"
        android:visibility="gone" >

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:contentDescription="@string/place" 
            android:src="@drawable/location_place" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/address1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"  
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:visibility="visible" />

            <TextView
                android:id="@+id/address2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" 
                android:textAppearance="?android:attr/textAppearanceSmall" />
        </LinearLayout>

    </LinearLayout>

</LinearLayout>

Here’s where we attach the BalloonView to the MapView
private MapView.LayoutParams getBalloonViewLayoutParams(GeoPoint where){
return new MapView.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
where, MapView.LayoutParams.BOTTOM_CENTER);
}

private void showBalloon(QPGeoPoint where) {
    latitude = where.getLatitude();
    longitude = where.getLongitude();
    BalloonView bv = getBalloonView();
    if(bv.getParent() != mapView){
        Ln.d("bv.getParent()!=mapView");
        mapView.addView(balloonView, getBalloonViewLayoutParams(where));
    }else{
        Ln.d("parent was map view");
        balloonView.setLayoutParams(getBalloonViewLayoutParams(where));
    }
    balloonView.setVisibility(View.VISIBLE);
    balloonView.setLocation(where); 
}

Other (possibly) relevant things:

  • We’re using ActionBarSherlock, RoboGuice, and the roboguice-sherlock plugin.

  • The application theme is set to Sherlock.Theme.Light.DarkActionBar, but the activity in question has it’s theme set to Theme.DeviceDefault.NoTitleBar.

I am completely baffled, have been trying to figure this out for hours, and will continue to do so and post updates as I find new clues.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:45:51+00:00Added an answer on June 12, 2026 at 7:45 pm

    Well ladies and gents, here it is:

    The text and background were both white. Touching the text set it’s color state to pressed, which made it black.

    The quick fix is to change the textColor attribute on the text view.

    A more general fix might be to use a different theme for this activity, say, Theme.DeviceDefault.Light.NoTitleBar.

    Feeling pretty dumb on this one ;P

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have come accross something very strange whilst trying to use deflate, I am
I have a very strange behavior in going on KnockoutJS 1.2.1 (Can't switch to
I have tried to use garchFit in R and found out something very strange,
Something very strange happened and I have no idea why. I've lost the icon
I have a very strange issue going on here. It's only occurring on Internet
I came accross something very strange when i was testing my pages in FireFox.
I'm applying UnitTest just for a while, and today I met something very strange.
I'm facing a apparently very strange problem (I must be doing something wrong, just
Something very odd is going on. I populate my array as follows: self.workingWithItemCollectionArray =
I have just found something very weird while developing a website. While trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.