How to align rigth one button

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

How to align rigth one button

Postby puxdroid » Thu Dec 03, 2009 12:16 am

Hello

I have this layout:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.    android:orientation="vertical"
  7.  
  8.    android:layout_width="fill_parent"
  9.  
  10.    android:layout_height="fill_parent"
  11.  
  12.    >
  13.  
  14.         <LinearLayout android:orientation="horizontal"
  15.  
  16.                 android:layout_width="fill_parent"
  17.  
  18.                 android:layout_height="wrap_content">
  19.  
  20.  
  21.  
  22.                 <TextView android:layout_width="wrap_content"
  23.  
  24.                         android:layout_height="wrap_content"
  25.  
  26.                         android:text="Text 1:" />
  27.  
  28.                
  29.  
  30.                 <TextView android:text="Text 2"
  31.  
  32.                         android:id="@+id/TextView01"
  33.  
  34.                         android:padding="3dip"
  35.  
  36.                         android:layout_width="wrap_content"
  37.  
  38.                         android:layout_height="wrap_content"/>
  39.  
  40.                
  41.  
  42.                 <ToggleButton
  43.  
  44.                         android:id="@+id/ToggleButton01"
  45.  
  46.                         android:layout_width="wrap_content"
  47.  
  48.                         android:layout_height="wrap_content"
  49.  
  50.                         android:layout_alignParentRight="true"/>
  51.  
  52.        
  53.  
  54.         </LinearLayout>
  55.  
  56.        
  57.  
  58.        
  59.  
  60.        
  61.  
  62. </LinearLayout>
  63.  
  64.  
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


I I wan to align Toogle Button to right, but
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. android:layout_alignParentRight="true"
  2.  
  3.  
Parsed in 0.000 seconds, using GeSHi 1.0.8.4

Doesn't work.

Can anybody help me?

Thanks in advance
puxdroid
Developer
Developer
 
Posts: 49
Joined: Wed Nov 25, 2009 11:57 am

Top

Postby Kur1310 » Thu Dec 03, 2009 9:31 am

Hi,
To make the following line working u have to use RelativeLayout instead of LinearLayout.
Since u have used LinearLayout, it's not taking its effect.

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2.  
  3.  
  4. android:layout_alignParentRight="true"
  5.  
  6.  
Parsed in 0.000 seconds, using GeSHi 1.0.8.4
-Kur
Kur1310
Junior Developer
Junior Developer
 
Posts: 20
Joined: Wed Oct 28, 2009 10:50 am

Postby puxdroid » Thu Dec 03, 2009 12:26 pm

Thanks! it works, but the other TexView have been top of each other.
Exist any syntax to avoid this?

I have done this, but I'm not sure if it is efficient or correct:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.    android:orientation="vertical"
  7.  
  8.    android:layout_width="fill_parent"
  9.  
  10.    android:layout_height="fill_parent"
  11.  
  12.    >
  13.  
  14.         <LinearLayout android:orientation="horizontal"
  15.  
  16.                 android:layout_width="fill_parent"
  17.  
  18.                 android:layout_height="wrap_content"
  19.  
  20.                 android:layout_marginTop="3dip">
  21.  
  22.  
  23.  
  24.                 <TextView android:layout_width="wrap_content"
  25.  
  26.                         android:id="@+id/Text1"
  27.  
  28.                         android:layout_height="wrap_content"
  29.  
  30.                         android:text="text 1" />
  31.  
  32.                
  33.  
  34.                 <TextView android:text="text 2"
  35.  
  36.                         android:id="@+id/Text2"
  37.  
  38.                         android:padding="3dip"
  39.  
  40.                         android:layout_width="wrap_content"
  41.  
  42.                         android:layout_height="wrap_content"/>
  43.  
  44.                        
  45.  
  46.                 <RelativeLayout android:orientation="horizontal"
  47.  
  48.                         android:layout_width="fill_parent"
  49.  
  50.                         android:layout_height="wrap_content">
  51.  
  52.                
  53.  
  54.                         <ToggleButton android:text="@+id/ToggleButton01"
  55.  
  56.                                 android:id="@+id/ToggleButton01"
  57.  
  58.                                 android:layout_width="wrap_content"
  59.  
  60.                                 android:layout_height="wrap_content"
  61.  
  62.                                 android:layout_alignParentRight="true"
  63.  
  64.                                 />
  65.  
  66.                 </RelativeLayout>
  67.  
  68.         </LinearLayout>
  69.  
  70. </LinearLayout>>
  71.  
  72.  
Parsed in 0.004 seconds, using GeSHi 1.0.8.4
puxdroid
Developer
Developer
 
Posts: 49
Joined: Wed Nov 25, 2009 11:57 am

Postby achie1266 » Thu Dec 03, 2009 6:05 pm

puxdroid wrote:Thanks! it works, but the other TexView have been top of each other.
Exist any syntax to avoid this?

I have done this, but I'm not sure if it is efficient or correct:


You can replace entire inner linear layout with relative layout and set each view as you need.
here is a good tutorial on how to do it.

http://developer.android.com/guide/tuto ... ayout.html

ou may want to check the tutorials provided in android documentation if you haven't already done so.
achie
User avatar
achie1266
Master Developer
Master Developer
 
Posts: 223
Joined: Mon Nov 09, 2009 10:56 pm
Location: Denver

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 6 guests