linearlayout

How to get an Android widget's size after layout is calculated?

I have a layout which specifies sizes of widgets in relative dimension, for example: <LinearLayout ... layout_height="fill_parent"> <ImageView ... layout_height="wrap_content" /> <TextView ... layout_height="120dp" /> </LinearLayout> Immediately after onCreate, I want to know how much is the height of the ImageView. How to d...

On Android, click to expand list -and- click on a button?

I have just started my career as an android programmer, and am currently relying heavily on the sample code and api examples. I have been working with this api example, to produce an expandable list of items (note this example does not use the ExpadableListView). In playing with the example, I tried to add another widget that would beco...

Proportional width of elements in LinearLayout

I have a horizontal LinearLayout and in it I have EditText and Spinner elements. Which attributes I need to adjust so I would get proportional widths: I want EditText to take 3/5 and Spinner - 2/5 of all available width? My code looks like this: <LinearLayout android:layout_height="wrap_content" android:layout_width="fill_par...

Help with Android LinearLayout or RelativeLayout

I need to create two views programmatically (because I need to access the ondraw of one of the views). For some reason, no matter what I do to add the views to the contentview, they don't show up vertically stacked, one below the other. I can do it just fine using the XML using a RelativeLayout and layout positioning, but with the XML ...

How do I get this linearlayout working on android?

I'm trying to create a scrollview that contains a linearlayout with some options inside of it. I'd like for the options to show up at the top and grow downwards, and to have "save," "delete," and "cancel" buttons which show up at the very bottom of the screen (if there is space left in between the bottom of all the options and the top of...

New to Android: Dynamically changing views

I'm trying to learn how to build apps for Android. The first simple app, which will become a component of a bigger app I hope to build, is to have a button on the screen where, when tapped, it adds something new to the view. For instance: Imagine a layout that only has a button: [Create!] When that button is pressed, the view gets ...

Android VideoView LinearLayout LayoutParams

My app plays a video using VideoView. I am using a LinearLayout to add some text, the video and then some buttons. My question is what kind of layout params can I use for the VideoView to make sure it plays well in all phones? Basically, when in portrait mode, I want the complete width to be used, and video height to be used. When in l...

Android -- RelativeLayout and LinearLayout -- VideoView resize issue

I am having a video resizing issue, I have to build the layout programatically, and here's my code: layout = new RelativeLayout(this); top = new RelativeLayout.LayoutParams( LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT); top.addRule(RelativeLayout.ALIGN_PARENT_TOP); RelativeLayout.LayoutParams middle = new Relativ...

Android: Add a textview to linear layout programmatically

Hi, I am trying to add TextViews to my xml-defined layout in code. I have a xml-sheet, where a lot of Views are defined. But I have to add some views in code, so a create a LinearLayout in the xml-sheet: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:id="@+id/info" a...

Android: Add two text views programmatically

Hi, I am trying to add Views to a linear layout programmatically. LinearLayout layout = (LinearLayout) findViewById(R.id.info); String [] informations = topOffer.getInformations(); TextView informationView; View line = new View(this); line.setLayoutParams(new LayoutParams(1, LayoutParams.FILL_PARENT)); lin...

[Android] Textview Selector when pressed

Hi all! I have a basic LinerLayout with a TextView and an ImageView I would like to do the same thing as with a button: when you click on this linear layout, the background changes. I can change the background when I focus the LinearLayout (with the trackball), but I can't when I click on it! And I don't know why. I tried a lot of thin...

LinearLayout in ExpandableListView

Hi guys, I want to inflate a childView of ExpandableChildView component. Code: public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { View v = convertView; LinearLayout linearOpt = themesOptions.get(childPosition); if(v == null) { ...

Stacking Two ImageButtons

I have two ImageButtons, and I am trying to stack one on top of the other. I essentially want to make a screen with two big buttons that each take up 50% of the available space. The code is below. Here is a capture of the layout it yields http://imgur.com/cQT0W.png I have played around with layout_gravity and gravity on the parent. Setti...

How do I prevent TextView from stretching out it's parent LinearLayout?

It seems that a TextView inside a LinearLayout forces that LinearLayout to be larger. I am trying split my screen top 50% and bottom 50% and also the bottom 50% is split into 3 parts. So I did my weights 3 (for the top), and then 1, 1, 1 (for the bottom) for a total of 6. Here is what it looks like. http://i.imgur.com/3FJSW.jpg As so...

Dynamic transparent background in my Android App Java

OK, So I want to set the background to a transparent image and change the color of the background on an event firing. I can set the background image to a resource in an xml file, and I can also change the color of a TextView on event firing, but for some reason I can't do both at the same time. Do I need to create a drawable or something...

Android VideoView scaling

I have a VideoView inside a LinearLayout. I want the video to scale so that in portrait, it shows up as the original width and height of the video, but in landscape, it should fill the screen as much as possible, leaving space on top for any other view above the Linear Layout. What parameters can I use? Thanks Chris ...

LinearLayout Center

I've a little problem with alignement in LinearLayout. I'm trying to have the frist two elements with left alignement, and the third at the center of the screen. Here is my code (cleaned from id, text, src) : <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:ori...

Problem with some advanced UI

Hi, I'm trying to create tables with rounded corners. I've quite a bit of XML to do this, but I have a problem. The table is wrapping itself to the width of its inner text. I want the entire thing to fill the parent (though I want a border around it so there is some cushion, which I have). I can't understand why it is not when I have...

Android view fills screen using linerlayout

Trying to write a game such that most of the screen gets filled with my GameView (custom view, derived from View) I then want to have an area at the bottom of the screen for messages etc. In the following I'm just trying to put a button there to illustrate the issue. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:...

Having issues with centering text in TextView within a region...

Hi, I'm having issues with TextViews and centering the text within the text region. Specifically, I have a TextView, but when I have text inside that contains letters that straddle down the bottom margin (i.e. p, g, q, y, etc), those letters are getting cut-off. I'm trying to center the text within the region but haven't had much luck...