I am having two TextView in LinearLayout.
<LinearLayout
android:layout_marginTop="-10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/product_discounted_price"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/activity_vertical_margin"
android:layout_marginEnd="#dimen/margin_between_prices"
android:drawablePadding="5dp"
android:gravity="center_vertical"
android:text="AED200000000.00"
android:textColor="#color/black"
android:textSize="#dimen/font_size_sub_normal"
android:visibility="visible" />
<TextView
android:id="#+id/product_unit_price"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/activity_vertical_margin"
android:drawablePadding="5dp"
android:gravity="center_vertical"
android:text="AED200000000000.00"
android:textSize="#dimen/font_size_emphasized"
android:visibility="visible" />
</LinearLayout>
I want something like if 2nd TextView doesnt come in single line than it should shift to second line.
Issue is :
With SingeLine=true
With maxLine=1
What I want :
change
android:orientation="horizontal"
to
android:orientation="vertical"
and also add maxline and singleline to textView
It is easy put your text views in a RelativeLayout and all you need to set layout_above or layout_bottom for your TextViews
or you can change orientation:vertical and then the gravity works.
You can also set layout_gravity
I'm programatically adding views into my layout inside a for loop.
The xml file of the layout I'm adding is like this one:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout_consulta_item_list"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/imageView_consulta_action"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/LinearLayout_dados_consulta"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/LinearLayout_dados_consulta"
android:layout_centerHorizontal="true"
android:layout_centerInParent="false"
android:adjustViewBounds="true"
android:maxWidth="70dp"
android:padding="10dp"
android:scaleType="centerInside"
android:src="#drawable/estrela_off" />
<LinearLayout
android:id="#+id/LinearLayout_dados_consulta"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_toLeftOf="#+id/imageView_consulta_action"
android:background="#660000"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:text="#string/origem"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#ffaaaa"
android:textSize="10sp" />
<TextView
android:id="#+id/textView_origem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="YYY"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#eeeeee" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:text="#string/data_ida"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#ffaaaa"
android:textSize="10sp" />
<TextView
android:id="#+id/textView_data_ida"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2014-05-05"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#eeeeee"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
In my main_activity, I call the constructor:
for (int i=0;i<resultList.length-1;i++){
RelativeLayout viewToLoad = (RelativeLayout)LayoutInflater.from(this).inflate(R.layout.consulta_item, null);
ll.addView(viewToLoad);
ImageView ImgConsulta_action = (ImageView)findViewById(R.id.imageView_consulta_action);
LinearLayout dados_consulta = (LinearLayout)findViewById(R.id.LinearLayout_dados_consulta);
dados_consulta.setOnLongClickListener(...);
ImgConsulta_action.setOnLongClickListener(...);
Well, I keep setting SetText for all the views in the layout and so on.
But, in order to make the setOnClickListener to work for each view, I must set a id to the views inside the for loop:
dados_consulta.setId(4000+i);
ImgConsulta_action.setId(5000+i); //(*lastline)
The weird thing is happening is that:
If I comment this last line, the layout is inserted correctly with the imageview showing a star as it is suposed to do and the listener at "dados_consulta" works fine.
But if I remove the comment at this last line, the star dissapear from the screen.
Can anybody help me to understand what is going on?
I had an layout params referenced to the ID of the layout elements at the original view.
Since I have to change the ID dynamically while I'm adding this layout several times into my activity, I also need to reset the layoutparams to the new Ids.
So, I added this lines:
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)ImgConsulta_action.getLayoutParams();
params.addRule(RelativeLayout.ALIGN_TOP, dados_consulta.getId());
params.addRule(RelativeLayout.ALIGN_BOTTOM, dados_consulta.getId());
ImgConsulta_action.setLayoutParams(params);
RelativeLayout.LayoutParams paramsDadosConsulta = (RelativeLayout.LayoutParams)dados_consulta.getLayoutParams();
paramsDadosConsulta.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
paramsDadosConsulta.addRule(RelativeLayout.LEFT_OF, ImgConsulta_action.getId());
dados_consulta.setLayoutParams(paramsDadosConsulta);
Now it's working perfectly.
Notice that the problem is not about the layout disappearing it was about a layout get in front of the other one. (making this other one invisible)
I am using the following xml to generate a row in a list view. Though i have set the gravity as center_Vertical and right. Only center_Vertical is applied but not the "right" gravity. I have even tried inside the code. the "right" gravity is not working. Kindly help me to correct the code.
Thanks in Advance
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/tvTicketID"
android:layout_width="wrap_content"
android:layout_height="52dp"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:gravity="center_vertical|left"
android:text="Ticket ID"
android:textSize="15dp" />
<TextView
android:id="#+id/tvCreationHour"
android:gravity="center_vertical|right"
android:layout_width="wrap_content"
android:layout_height="52dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="40dp"
android:layout_toRightOf="#+id/tvTicketID"
android:text="Hour" />
<TextView
android:id="#+id/tvTableNumber"
android:gravity="center_vertical|right"
android:layout_width="wrap_content"
android:layout_height="52dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="24dp"
android:layout_toRightOf="#+id/tvCreationHour"
android:text="Table #" />
<TextView
android:id="#+id/tvAmount"
android:gravity="center_vertical|right"
android:layout_width="wrap_content"
android:layout_height="52dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="18dp"
android:layout_toRightOf="#+id/tvTableNumber"
android:text="Amount" />
</RelativeLayout>
The code I use to create a row using the above xml
holder.tvTicketID.setText(String.valueOf(ticket.getId())) ;
holder.tvCreationHour.setText(String.valueOf(ticket.getCreationHour())) ;
holder.tvTableNumber.setText(String.valueOf(ticket.getTableNumber())) ;
holder.tvAmount.setText(String.valueOf(ticket.getTotalAmount())) ;
Try setting android:layout_gravity="right"
In general, android:gravity="right" is different from android:layout_gravity="right".
The first one affects the position of the text itself within the View, so if you want it to be right-aligned, then layout_width= should be either "fill_parent" or "match_parent".
The second one affects the View's position inside its parent, in other words - aligning the object itself (edit box or text view) inside the parent view.
Finally, I fonund the answer. I have changed the android:layout_width="wrap_content" in the TEXTVIEW to android:layout_width="30dp". Now it works..
Hi I have developed the UI like the screen below.Now I want to add the last row in the UI on last plus button click event.
I know how to add Button or EditText dynamically but I am not getting how can I add and delete row which is having multiple column dynamically.
Edit:- One Important thing about last row is each column is editable.That means I need the reference of each column for getting it's content.When I am adding row dynamically plus button should get placed in new row.Similarly if I remove row row plus button should get shifted to the upper row.
How can I do this.Any guideline or any approach will be appreciated.
This is my XML file.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#drawable/navi_bar" />
<Button
android:id="#+id/title_bar_btnBack"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:background="#drawable/back_button_image" />
<Button
android:id="#+id/title_bar_btnExport"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/title_bar_btnBack"
android:layout_marginRight="10dp"
android:background="#drawable/export_button_normal" />
<!-- Create PDF Part 2 -->
<ImageView
android:id="#+id/pdf_Upper_Image"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/title_bar_btnBack"
android:background="#drawable/grid_bg_part1" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/pdf_Upper_Image"
android:layout_alignParentLeft="true"
android:text="Kassenbuch"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#3EC7F9"
android:textSize="23dp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button1"
android:layout_marginLeft="10dp"
android:layout_marginTop="2dp"
android:layout_toRightOf="#+id/textView1"
android:text="Name :"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView2"
android:layout_alignTop="#+id/textView2"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/textView2"
android:text="Akshay"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<!-- Custom Pdf Part 2 -->
<ImageView
android:id="#+id/pdf_Middle_Image"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/pdf_Upper_Image"
android:background="#drawable/grid_bg_part2"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
/>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="#+id/pdf_Middle_Image"
android:layout_marginLeft="2dp"
android:text="Einnahmen"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/txtName"
android:layout_alignTop="#+id/txtName"
android:layout_marginLeft="82dp"
android:layout_toRightOf="#+id/txtName"
android:text="Month :"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView1"
android:layout_alignBottom="#+id/textView1"
android:layout_alignLeft="#+id/textView4"
android:layout_marginBottom="2dp"
android:text="Mand Nr. :"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<TextView
android:id="#+id/txtMand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView5"
android:layout_alignTop="#+id/textView5"
android:layout_toRightOf="#+id/textView5"
android:text="Mand"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<TextView
android:id="#+id/txtMonth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/txtName"
android:layout_alignTop="#+id/textView4"
android:layout_toRightOf="#+id/textView5"
android:text="05"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp"
/>
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/txtYear"
android:layout_alignTop="#+id/txtMonth"
android:layout_toLeftOf="#+id/title_bar_btnExport"
android:text="Year :"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView5"
android:layout_alignBottom="#+id/textView5"
android:layout_alignLeft="#+id/textView8"
android:text="Blatt :"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<TextView
android:id="#+id/txtYear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/txtMonth"
android:layout_alignLeft="#+id/title_bar_btnExport"
android:layout_alignTop="#+id/txtMonth"
android:text="2012"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/pdf_Middle_Image"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/textView3"
android:text="Ausgabne"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9" >
</TextView>
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/pdf_Middle_Image"
android:layout_marginLeft="15dp"
android:layout_toRightOf="#+id/textView6"
android:text="Bestand"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9" />
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/pdf_Middle_Image"
android:layout_toLeftOf="#+id/txtMand"
android:text="Datum"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9" />
<TextView
android:id="#+id/textView13"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/pdf_Middle_Image"
android:layout_toLeftOf="#+id/textView5"
android:text="Beleg Konto"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="8dp" />
<TextView
android:id="#+id/textView14"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView13"
android:layout_alignTop="#+id/pdf_Middle_Image"
android:layout_marginRight="03dp"
android:layout_toLeftOf="#+id/textView13"
android:text="Gegen Konto"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="08dp" />
<TextView
android:id="#+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView3"
android:layout_alignRight="#+id/textView1"
android:layout_below="#+id/textView14"
android:text="Anfangsbestand/Ubertrag"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="9dp" />
<TextView
android:id="#+id/textView11"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView13"
android:layout_alignTop="#+id/pdf_Middle_Image"
android:layout_marginLeft="25dp"
android:layout_toRightOf="#+id/textView12"
android:text="USt satz."
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="09dp" />
<TextView
android:id="#+id/txtBlatt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView9"
android:layout_alignBottom="#+id/textView9"
android:layout_toRightOf="#+id/textView9"
android:text="Blatt"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView11"
android:layout_alignLeft="#+id/textView9"
android:text="Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9" />
<include android:id="#+id/firstRow"
layout="#layout/custom_pdf3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/pdf_Middle_Image"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"/>
</RelativeLayout>
Thanks
Create a layout that represents a complete row,then you can use:
public View inflate (int resource, ViewGroup root) from LayoutInflater(a class in android.view package) to Inflate a new view hierarchy from the specified XML resource(for example your new row).
Now you can add this view(your row) dynamically to your main layout with a specific tag(like adding a button dynamically to the layout).
Create an XML layout file, which will represent a 'row in the list view.
Implement a custom Adapter, using base Adapter.
In the getView() method, Inflate the Xml layout, Reference the inner items (using outerLayout.findViewById(), set Listeners right there, and Finally return the view.
Write the implementation for your listener.
Simple enough? :-)
Try creating the whole layout at runtime. Create a single row containgin all ur columns and set visibility of the last one to gone. Change the visibility when the plus button is pressed.
Creating a row of type Relative layout will be good i think. When u want to remove a row Then you will have to count the Relative layouts in the main layout and then remove the index which u want to remove.
I think you will understand best through an example. Lets simplify things a little bit. Lets say your main layout is this:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/main_layout" >
</TableLayout>
It's a simple TableLayout without any views yet (You could have pre-baked rows in it). Now you want to create TableRows wich you want to add dinamically, and handle it's subviews separately, right? You could create your whole TableRow in xml:
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tablerow_textview"
android:text="Hello" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tablerow_button"
android:text="World" />
</TableRow>
Then the java part. Lets say you want to add 10 of those rows to your TableLayout, and handle each rows button and separately. You can do it like this (You must have access to a Context object):
// get the main TableLayout from xml
TableLayout layout = (TableLayout) findViewById(R.id.main_layout);
// get a LayoutInflater object. 'this' is the current Activity
LayoutInflater inflater = LayoutInflater.from(this);
for(int i=0; i<10; i++)
{
//Create an inflated instance of that layout
TableRow row = (TableRow) inflater.inflate(R.layout.table_row, null);
//Notice, that we call the findViewById() function on the previously
//inflated layout, which means, that we can only access its subviews
Button rowButton = (Button) row.findViewById(R.id.tablerow_button);
TextView rowText = (TextView) row.findViewById(R.id.tablerow_textview);
//Now that you have those Views, you can do whatever you want with them, (set
an onClickListener, change the text, etc)
//finally we need to add the row to the table
layout.addView(row);
}
It would also be a good idea if you wrapper created a class for your inflated layout, with its own getter-setter functions, and you could just instantiate it with the new operator, and all the inflation would be done in the background.
You need to work with custom views. Then each view can be a complex view and you can do what ever you wish, this task should not be easy.
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button1"
android:layout_marginLeft="10dp"
android:layout_marginTop="2dp"
android:layout_toRightOf="#+id/textView1"
android:text="Name :"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<com.sample.MyCustomView
android:id="#+id/myView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
And then MyCustomView can be Linear Layout or what ever.
In above xml
you did all the things in Textview and adjust that
instead of using that you have to create a Tablelayout in your xml file.
onButtonClick event you have to create a new tablerow dynamically then add components by using tablerow.addview(componentsname) and finally add tablerow to tablelayout
Simple TableLayout
After trying lot of different things I solved my problem like below.I made certain changes in my xml.I used LinearLayout with ScrollView.
And I created one xml file which is having complete row.Now my task is to add that xml in the LinearLayout which I did in the following manner.I am calling this method on button click event at each time.
public void AddDynamicView() {
linearLayout = (LinearLayout) findViewById(R.id.show_pdfTableLayout);
layoutInflater = (LayoutInflater) getApplicationContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
view = layoutInflater.inflate(R.layout.custom_pdf3, null);
linearLayout.addView(view);
list.add(view); // Here I have created list of View so that I can get the id of specific view.
}
I have tried this with TableLayout but I was having some issue with occupying whole row.That's why I had used LinearLayout.
Probably I didn't understand well!!!
You can do everything mentioned in the question using ListView and Adapter.
You can provide an array to hold fields, feed an adapter with the array and feed listView with adapter.
If you need a new Row just add an element to the array.
If you want to delete a Row, just remove it from array.
If you want to sort items, just sort the array.
If you want to select prev/next, just use listview selection method.
I was wondered you checked your answer that is not absolutely correct approach. It's true but if your target ui is complex, the page will need a lot of time to render and scroll than ListViews that is dynamic and optimized.
If you think my answer sounds good, Let me know to update it with some code.
i am doing an xml layout file, and i want to have my spinner in the right of a textview, but i am having problems... when i test the layout, my spinner is not in the correct possition, it's a little more down and it haves very small lenght, is not 180px as i said in the layout.
there is the xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/PermissionLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/perlabel"
android:layout_marginLeft="15dip"
android:layout_below="#id/salto3"/>
<Spinner
android:id="#+id/Permission"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:prompt="#string/perlabel"
android:layout_alignBaseline="#id/PermissionLabel"
android:layout_alignParentRight="true"
android:width="180px"
android:layout_marginRight="20dip"/>
<TextView
android:id="#+id/salto4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/saltodelinea2"
android:layout_below="#id/PermissionLabel"/>
<TextView
android:id="#+id/HoursRangeLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hoursrangelabel"
android:layout_below="#id/salto4"
android:layout_marginLeft="15dip"/>
<EditText
android:id="#+id/From"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:layout_alignBaseline="#id/HoursRangeLabel"
android:width="70px"
android:layout_alignLeft="#id/Email"
android:layout_marginRight="20dip"/>
<TextView
android:id="#+id/ToLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tolabel"
android:layout_alignBaseline="#id/From"
android:layout_toRightOf="#id/From"
android:layout_marginLeft="-10px"/>
<EditText
android:id="#+id/To"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:layout_alignBaseline="#id/From"
android:width="70px"
android:layout_marginRight="20dip"
android:layout_alignParentRight="true"/>
Is it really necessary that all items in your layout are "Relative" to each other? It sure doesn't appear that way from the properties you set on each item.
I would recommend trying something like a LinearLayout, and then if it is critical a certain item is Relative to another item, use a RelativeLayout inside the LinearLayout for those particular items.