view overlap

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


Sponsored Links
 i

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

Custom_view.xml


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/widget28"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
<ImageView
android:id="@+id/imageview01"
android:layout_width="96px"
android:layout_height="86px"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true">
</ImageView>
<TextView
android:id="@+id/textview01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_below="@+id/imageview01"

</TextView>
</RelativeLayout>

Gallery.java

package com.android.rss;




import android.app.Activity;
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 ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gallery_1);

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

// Set a item click listener, and just Toast the clicked
position
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
registerForContextMenu(g);
}

@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
menu.add("testing");
}

@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo)
item.getMenuInfo();
Toast.makeText(this, "Longpress: " + info.position,
Toast.LENGTH_SHORT).show();
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 <coolcool.shal...@gmail.com> 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.
 http://developer.android.com/resources/tutorials/views/hello-relativelayout.html 

-------------------------------------------------------------------------------------------------
TreKing < http://sites.google.com/site/rezmobileapps/treking> ; - Chicago
transit tracking app for Android-powered devices

--



Other Threads

1. Display android screen on projector

Hi,

I have made an android application. Now I want to demonstrate the
application to a group of people.

How can I show my android screen live on a projector through a
laptop/desktop.

Thanks,
Nishant

-- 

2. Default Android Applications

:


-- 

3. XMPP Connection error

4. Seting prox

5. why is there no android tablet nearly as good as ipad?

6. Discrepancy between Active Installs and number of purchases

7. LocationManager.getSpeed(); always zeroo