Two elements in the same line. Problem with width ;)

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Two elements in the same line. Problem with width ;)

Postby PinkFly » Mon Feb 01, 2010 8:01 pm

Hello, I have a big problem.
I have a simple view on which i have (on the same line) EditText on left side and Button on the right. Everythink is ok in vertical orientation because edittext and button have static width. Problem is in landscape orientation because edittext is too short. I want that to edittext starts on the left edge of screen and ends on left edge of the button which is on the right from edittext. I want it to happen automatically.I dont know how i should to do it. When I set fill_parent on the edittext then it is too wide and button disappear. How to set the edittext width on 100%

Below simple diagram.
Image



and part of my layout
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <AutoCompleteTextView android:id="@+id/search_entry"  android:layout_width="230dip"
  2.                 android:layout_height="wrap_content" />
  3.  
  4. <Button android:id="@+id/search"  android:layout_width="80dip"  android:layout_alignParentRight="true" android:layout_toRightOf="@id/search_entry"  android:layout_height="wrap_content" android:text="Search" />
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


Thanks for help
PinkFly
Freshman
Freshman
 
Posts: 2
Joined: Mon Nov 02, 2009 8:29 pm

Top

Postby PinkFly » Mon Feb 01, 2010 8:51 pm

Ok, I have had a glare

We can make it like below...

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:padding="5dip"
  3.  
  4.         android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#E7E2E6">
  5.  
  6.        
  7.  
  8.         <AutoCompleteTextView android:id="@+id/search_entry"  android:layout_width="fill_parent"
  9.  
  10.                 android:layout_height="wrap_content" android:layout_marginRight="85dip"  />
  11.  
  12.        
  13.  
  14.         <Button android:id="@+id/search"  android:layout_width="80dip"  android:layout_alignParentRight="true"
  15.  
  16.                  android:layout_height="wrap_content"
  17.  
  18.                 android:text="Search" />
  19.  
  20.  
  21.  
  22. ....
  23.  
  24.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4
PinkFly
Freshman
Freshman
 
Posts: 2
Joined: Mon Nov 02, 2009 8:29 pm

Postby jwei512 » Tue Feb 02, 2010 7:40 am

And if that doesn't work, you can always create a layout-land folder and make a landscape version of the same page.
- jwei

http://thinkandroid.wordpress.com
Examples, Code, and Tutorials
jwei512
Senior Developer
Senior Developer
 
Posts: 135
Joined: Mon Jul 27, 2009 9:35 pm
Location: Palo Alto, CA

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests