Android :: ListActivity - When Using With RelativeLayout
May 16, 2010
I've been progressively expanding my UI, and I want to add a ListView in the middle of my UI. When I add it and change the activity to extend a ListActivity instead of just an Activity, I'm getting a Force Close. Using 1.5. Does a ListView not work embedded in a RelativeLayout?
CODE:.........
XML looks like this:
CODE:..........
And the listrow.xml:
CODE:.............
View 2 Replies
May 6, 2010
I have a Relative Layout.
Which has 2 buttons, side by side and it is right-aligned.
So this is my layout xml file. My question is there are no spacing between the right-most button and the right border of the RelativeLayout and between the 2 buttons. How can I add that? I play with android:paddingRight, but nothing helps. code...
View 3 Replies
View Related
Jan 22, 2009
There is an repeating background attribute like in css for layout on Android API?
View 5 Replies
View Related
Jul 15, 2009
I know my original post (at http://groups.google.com/group/android-developers/browse_thread/threa..., I could not find a way to perform a reply, maybe it's too old) is not sexy, but I'm now facing that problem in many situations. Let me please rephrase what I attempt to do, and what my problem is.
I have a RelativeLayout made of three widgets (named 1, 2 and 3 on the illustrations below): one attached to its parent left border (labelled 1), one to its parent right border (labelled 2) and the third (labelled 3) inserted between the 2 previous ones (its left border is attached to the first widget right border, and its right border is attached to the second widget left border). The third widget (the middle/central one laballed "3") is far taller than the two others, and I would like the first and second items (1 and 2) to be vertically centered with the middle widget.
I have resorted to the "android:layout_centerVertical" attribute for both the first and second widget, but I do not get the expected result. See at the bottom the various layouts I'm mentionning. Could someone please help me, and tell me whether what I intend to do is feasible, and how? Thank you for your time.
Layout with no "android:layout_centerVertical" specified: ------- |1|3|2| --|3|-- |3| ---
Layout with "android:layout_centerVertical" set to "true":
--- |3| |3| |3| ------- |1| |2| --- ---
What I'd like: --- --|3|-- |1|3|2| --|3|-- ---
View 11 Replies
View Related
Nov 1, 2010
I've always been using RelativeLayout everytime I needed a View container, because of it's flexibility, even if I just wanted to display something really simple.Is it ok to do so, or should I try using a LinearLayout when I can, from a performance/good practices standpoint?
View 1 Replies
View Related
Oct 27, 2010
I want a RelativeLayout to have a rounded corner just like we have it in the Iphone.Please let me know how can we do this in Android.
View 2 Replies
View Related
Sep 20, 2010
I'm trying to center a button in relative layout, is this possible? I've tried the Gravity and Orientation functions but they don't do anything.
View 3 Replies
View Related
Oct 13, 2010
Can anyone point me to a good one?
View 2 Replies
View Related
Mar 17, 2010
I have a problem with two Textviews on the same height in a RelativeLayout running into each other.
I use the following Layout.
CODE:...........
This gives me this view:
Everything is as I need it except the two textviews name and information are displayed on the same screen space with the one on top of the other.
View 2 Replies
View Related
Nov 24, 2010
Since I'm still just learning Android (and it appears Amazon says it'll be 2 months till I get the Hello, Android book) I'm still playing around with doing simple things. I have no problem getting an icon to display with the click of a button on my RelativeLayout using ImageView. The code for creating it is as follows:
private int mIconIdCounter = 1;
private ImageView addIcon(){
ImageView item = new ImageView(this);
item.setImageResource( R.drawable.tiles );
item.setAdjustViewBounds(true);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT );
if( mIconIdCounter != 1 ){
params.addRule(RelativeLayout.RIGHT_OF, 1 );
}
item.setLayoutParams( params );
item.setId( mIconIdCounter );
++m_IconIdCounter;.......................
View 2 Replies
View Related
Jul 27, 2010
Can anyone tell me how can i do this using Java code or in activity class? I do not know how to set android: layout_alignParentBottom="true".I want to implement whole view via java code.
View 1 Replies
View Related
Apr 28, 2010
I'm trying to build an android application that features a graphical display drawn within a RelativeLayout. I want to place "+" and "-" buttons next to several of the parameters, which are drawn at various points on the canvas. The positions are free-form don't seem to conform to any of the standard XML layouts.I know how to create the buttons programmatically, but I don't know how to place them over the canvas where I need them to be. I'm assuming that this would be done in the view thread's doDraw() method, after all the graphics have been drawn, but how?
View 2 Replies
View Related
Nov 9, 2010
I have ScrollView with RelativeLayout as a child of ScrollView. I am trying through JAVA code to set Layout_Gravity to CENTER so my RelativeLayout is centered (horizontally and vertically) in the middle of ScrollView (that covers whole screen).This works fine in XML and produces desired result, but when I try to do this programmatically, it seems there is no way to set Layout_Gravity of RelativeLayout. I tried using LayoutParams, but couldn't find anything there that would help me to center RelativeLayout in the middle. So, am I missing something or this simply can't be done?
View 7 Replies
View Related
Apr 23, 2010
I have the following structure defined in an xml layout file.
<RelativeLayout android:id="@+id/mainLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<FrameLayout android:id="@+id/frame" android:layout_centerInParent="true" android:layout_width="wrap_content" android:layout_height="wrap_content" ></FrameLayout>
<Button android:id="@+id/button" android:layout_below="@id/frame" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</RelativeLayout>
The FrameLayout is positioned correctly in the center of its parent. But the Button isn't getting positioned under it. Instead it's displaying in the top left corner. Am I doing something incorrectly or is this a bug with RelativeLayout?
View 1 Replies
View Related
Jun 9, 2010
As i am facing limitation of layout depth in my application, i am replacing some LinearLayout with RelativeLayout. However i am stopped by a supposely very simple issue (but apparantly without clean solution regarding that http://stackoverflow.com/questions/1499555/android-layout-centering-i..., nor in the ApiDemos sample where RelativeLayout are too simple):
How can i align vertically 3 items (in a simple way!) which are on a horizontal line with RelativeLayout without?
does not seem to have any effect at all.
Here is the xml; in this example i would like an icon at left (fixed width), a text label in the middle (fixed width) and an edit text on the right (remaining space). the problem is that the TextView seems to ignore the parameter android:layout_gravity="center_vertical", and seems to be top aligned with parent. code...
Of course i can use marginTop/Bottom and alignTop/Bottom on each single item but that's not very clean.
View 3 Replies
View Related
Jul 14, 2010
I created a background .png for my application in GIMP. It's resolution is 640x480, which from googling, seems to be the resolution for a default emulator. My problem is when I apply the background to the RelativeLayout with android:background=@drawable/bg and run it, there are lots of artifacts in the image. As if the emulator could not provide enough colors to display the .png correctly. This image is nothing to fancy, just simple lines and radial gradients.
View 1 Replies
View Related
Nov 15, 2010
In my Android App Activity, I have a RelativeLayout with one ImageView and a couple of TextViews being populated at runtime. I also have a Save button in the activity that I use to save the image in the ImageView to the device SD Card. Now what I really want to do is Convert the elements (image and the text in the RelativeLayout) together to a PNG image when the Save button is clicked and Save it to the SD Card. Have anyone tried a conversion like this before? It would be very helpful if someone can give me some hints or code snippets on how to go about doing this?
View 1 Replies
View Related
Aug 21, 2010
I'm starting to use RelativeLayout more and more but there are some things I keep running into.
Say I have a status textview that I want top and center. Then I have a bunch of other objects below it like images and a table layout.
I want the stuff below the status text view to respect the status textview's personal space and not draw themselves right on top of it.
But what I'm seeing is that in a relativelayout, everything piles up on eachother unless I use alignment such as android:layout_below and android:layout_above.
Is there an attribute that I can add to the status textview to make it so other objects don't want to draw right on top of it? Or do I have to keep using the alignment tags on everything and align things away from it?
View 1 Replies
View Related
Jun 7, 2010
I have an Android Activity with a RelativeLayout and I have implemented the following method to prevent the activity from being recreated on change of Orientation:
CODE:..............
I am obviously not doing anything in this method, but it worked perfect when using a LinearLayout. Now however, using RelativeLayout, my layout is all messed up when changing to landscape orientation.
What is the most efficient way to have the screen redraw correctly without having the activity restarted again with a call to onCreate?
View 2 Replies
View Related
May 31, 2010
<<LinearLayout>>.getLayoutParams() returns <<RelativeLayout>>.LayoutParams? I found that happends and so freaked. Is there any reason? or just a bug? it's eclair.
View 2 Replies
View Related
Apr 13, 2010
I have a RelativeLayout defined in xml and I call the setContentView(R.layout.relativeLAyout) for displaying in Activity. Now, if I want to resize this RelativeLayout then can it be done and if yes, then can someone let me know how? The inner components can be resized relatively to the parent.
View 7 Replies
View Related
Jun 18, 2010
I am trying to display two TextViews in two separate line. For that, I am using RelativeLayout. I don't want to use XML for layout as I want to bundle this Activity in a jar file which may be used by different APKs. The TextViews are being overlapped instead of being displayed on two separate lines. Any idea what I am doing wrong here? Sample code is below.
View 2 Replies
View Related
Aug 19, 2010
I am dynamically adding ImageViews to a RelativeLayout depending on user input. I have also created a button that when pressed, should clear all of the content of that RelativeLayout (remove all children). I was hoping for a .clear() method, but no such luck.
can someone point me in the right direction here?
RelativeLayout rel = (RelativeLayout) findViewById(R.id.iv_section);
rel.SomethingToRemoveAllChildren();
View 1 Replies
View Related
Apr 29, 2010
I'm currently working on a small update to a project and I'm having an issue with Relative_Layout and fill_parent in a list view. I'm trying to insert a divider between two sections in each row, much like the divider in the call log of the default dialer. I checked out the Android source code to see how they did it, but I encountered a problem when replicating their solution.
To start, here is my row item layout:
CODE:..........
The issue I'm facing is that each row has a thumbnail of varying height (ImageView01). If I set the RelativeLayout's layout_height property to fill_parent, the divider does not scale vertically to fill the row (it just remains a 1px dot). If I set layout_height to "?android:attr/listPreferredItemHeight", the divider fills the row, but the thumbnails shrink. I've done some debugging in the getView() method of the adapter, and it seems that the divider's height is not being set properly once the row has it's proper height.
Here is a portion of the getView() method:
CODE:.........
The rest of the method simply sets the appropriate text and images for the row.
Also, I create the inflater object in the adapter's constructor with: inflater = LayoutInflater.from(context);
Am I missing something essential? Or does fill_parent just not work with dynamic heights?
View 1 Replies
View Related
Aug 20, 2010
I have a layout that has just a ScrollView visible. It has a relative layout as its child. This layout has several other layouts (mainly text views) as its children. When the text is not big enough, the scroll view does not expand itself to fit the whole screen. Instead, it shows a gap at the bottom where the background shows. I tried setting fillViewPort=true on the ScrollView, but that just made the first child layout (RL1) to fill the screen.
CODE:....................
View 1 Replies
View Related
Oct 11, 2010
I want to create a relative Layout dynamically through code with 2 Textviews one below the other.How to implement android:layout_below property through code in Android.
View 1 Replies
View Related
Oct 26, 2009
I'm trying to create an application that has 3 tabs. Under the middle tab should be a ListView. It starts up fine (on the left tab) but when I click the middle tab it crashes.
The other two tabs are static data specified in the main.xml file. But the middle tab, I try to create dynamically. Here's the code from the main onCreate function:
CODE:...............
Instead I appear to get an exception:
CODE:...............
ContactListActivity is defined this way:
public class ContactListActivity extends ListActivity { ...
I get the feeling that I'm supposed to create the Intent with something like Intent.ACTION_VIEW but this is where I get lost. If this is the problem, I could try stuff until it works, but I'd prefer to understand why.
Or is ContactListActivity supposed to override something ?
View 2 Replies
View Related
Feb 8, 2010
I have a problem with rotation, during my ListActivity is loading data from the network. To do it I use a background thread which recovers data and put them inside an ArrayList. While this thread works, there is Progress dialog activated in foreground. For the rotation I use the method with onRetainNonConfigurationInstance() to save my ArrayList's state. After android calls this method, I call dismiss() on the progress dialog on onStop(). Then the activity is created as new with onCreate(), but it use the getLastNonConfigurationInstance() to recover the ArrayList's state. Now, my problem. If I rotate from portrait to lanscape when the download is terminated and I see the data in portrait yet, everything is ok. If I rotate during progress dialog is showing I have two cases: 1- onRetainNonConfigurationInstance() saves the arraylist fully recovered, the thread terminates and everything is ok. 2- onRetainNonConfigurationInstance() saves the arraylist empty, i think the download isn't finished yet. The onCreate is called and my list is empty, the thread terminates, but i don't see anything in my list. If I am in this case and I still rotate from landscape to portrait now I can see my list full with all the data. Why? Where am I wrong?
View 7 Replies
View Related
Jun 30, 2009
I create a ListView in my activity and set its ChoiceMode to CHOICE_MODE_SINGLE, I also set its layout to simple_list_item_single_choice. But when i click on it onItemSelected() is never called and getCheckedItemPosition() returns -1. Why? the sample List10.java of ApiDemos uses ListActivity works well which just set the same as I done in my app. Any ideas?
View 2 Replies
View Related
Jan 13, 2010
I want to create a custom list view in my application. I want it to lay over the top of the application screen, with portions of the screen not filled by the listview showing the underlying application. I've been reading about ListActivity, how it can be started to handle item selected callbacks. I've also read about people simply inserting onClick handlers into the listview as it is drawn. I'm trying to decide the best way to proceed. Is it "dirty" to attach onClick handlers to the rows of a listview? It doesn't seem like the best approach, for instance, it only handles Touch Mode, not the DPAD clicks. This approach doesn't seem like what the architects had in mind. On the other hand, I don't see a good way that I can start a list activity and still have access to all the application variables I need. Do I pass the application in the context and refer back to it from even handlers after casting the context back to it's original class?
View 5 Replies
View Related