view overlap

by Shalini » Thu, 18 Nov 2010 18:32:18 GMT

Sponsored Links

I had created a custom view as gallery item. My custom view contains
an image view and a textview. I want textview to be below of imageview
but it overlaps. Please how to do this


<?xml version="1.0" encoding="utf-8"?>



import android.content.Context;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;

public class Gallery1 extends Activity {

private class viewHolder{
private TextView text;
private ImageView image;
Gallery g ;
public void onCreate(Bundle savedInstanceState) {

// Reference the Gallery view
g = (Gallery) findViewById(;
// Set the adapter to our custom adapter (below)
g.setAdapter(new ImageAdapter(this));

// Set a item click listener, and just Toast the clicked
g.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int
position, long id) {
Toast.makeText(Gallery1.this, "you have selected : " +
position, Toast.LENGTH_SHORT).show();

// We also want to show context menu for longpressed items in
the gallery

public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {

public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo)
Toast.makeText(this, "Longpress: " + info.position,
return true;

public class ImageAdapter extends BaseAdapter {
int mGalleryItemBackground;
private LayoutInflater m

view overlap

by sathvik » Thu, 18 Nov 2010 18:37:55 GMT

 ay be parent container of ur custom view is not allowing your textview to
get below the imageview , increase the height of parent container and check
, check by giving marginTop (though it might not be the right soln)

On Thu, Nov 18, 2010 at 4:02 PM, Shalini <> wrote:


Sponsored Links

view overlap

by TreKing » Fri, 19 Nov 2010 05:03:35 GMT


When using a RelativeLayout, you must specify what each child is laid out
relative to. Otherwise the layout just stacks them, as you have seen. 

TreKing <> ; - Chicago
transit tracking app for Android-powered devices


Other Threads

1. EditTextPreference question

I've got an EditTextPreference within PreferenceActivity.

I'd like to store the value in an encrypted format - but
display it normally.

how do i intercept the saving - so that i can encrypt it.

how do i intercept the value just before display - so that
i can decrypt it.


2. Ang.: Ang.: 2.3 Platform Google APIs missing Licensing Service..?

Yes, I know. The app I tried uses LVL r1 (which is built using Android 1.5, 
level 3) as a library. The app itself is built using Android 2.1 update 1, 
i.e. level 7. I get the error on AVDs running Google APIs level 9, 11, 12, 
but on level 8 licensing works. It is the same .apk file I have been using 
in all cases. I have not tried level 10. Level 7 is out of the question as 
an AVD with Google API level 7 does not support licensing. Same .apk file 
also works fine on real devices running level 7 and 8.


3. Hostapd support in android 3.1

4. porting is done on

5. Trouble with ListView - adding items, refresh, order in the list...

6. AudioRecord and AudioTrack

7. Video recording