Tab Layout pushes away button

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

Tab Layout pushes away button

Postby tbi » Fri May 29, 2009 8:48 am

Hey,

In one Activity I have a Tab Layout containing 3 Scroll Views and a "confirm" button beneath. That button should always be visible at the bottom, hence I can't put seperate buttons in the respective scroll views. What I did to try and solve the problem was the following:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3.  
  4.  
  5. <LinearLayout android:orientation="vertical"
  6.  
  7.         xmlns:android="http://schemas.android.com/apk/res/android"
  8.  
  9.         android:layout_width="fill_parent" android:layout_height="fill_parent">
  10.  
  11.  
  12.  
  13.         <TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent"
  14.  
  15.                 android:layout_height="wrap_content">
  16.  
  17.  
  18.  
  19.                 <LinearLayout android:orientation="vertical"
  20.  
  21.                         android:layout_width="fill_parent" android:layout_height="wrap_content">
  22.  
  23.  
  24.  
  25.                         <TabWidget android:id="@android:id/tabs"
  26.  
  27.                                 android:layout_width="fill_parent" android:layout_height="wrap_content" />
  28.  
  29.                         <FrameLayout android:id="@android:id/tabcontent"
  30.  
  31.                                 android:layout_width="fill_parent" android:layout_height="wrap_content">
  32.  
  33.  
  34.  
  35.                                 <ScrollView android:id="@+id/shared_params"
  36.  
  37.                                         android:orientation="vertical" android:layout_width="fill_parent"
  38.  
  39.                                         android:layout_height="wrap_content" android:scrollbars="vertical">
  40.  
  41.  
  42.  
  43.                                         <!-- ... -->
  44.  
  45.  
  46.  
  47.                                 </ScrollView>
  48.  
  49.  
  50.  
  51.                                 <ScrollView android:id="@+id/find_params"
  52.  
  53.                                         android:orientation="vertical" android:layout_width="fill_parent"
  54.  
  55.                                         android:layout_height="wrap_content" android:scrollbars="vertical">
  56.  
  57.  
  58.  
  59.                                         <!-- ... -->
  60.  
  61.  
  62.  
  63.                                 </ScrollView>
  64.  
  65.  
  66.  
  67.                                 <ScrollView android:id="@+id/struct_params"
  68.  
  69.                                         android:orientation="vertical" android:layout_width="fill_parent"
  70.  
  71.                                         android:layout_height="wrap_content" android:scrollbars="vertical">
  72.  
  73.  
  74.  
  75.                                         <!-- ... -->
  76.  
  77.  
  78.  
  79.                                 </ScrollView>
  80.  
  81.                         </FrameLayout>
  82.  
  83.                 </LinearLayout>
  84.  
  85.         </TabHost>
  86.  
  87.         <Button android:id="@+id/filter_confirm" android:text="@string/confirm"
  88.  
  89.                 android:layout_width="wrap_content" android:layout_height="wrap_content" />
  90.  
  91. </LinearLayout>
Parsed in 0.006 seconds, using GeSHi 1.0.8.4


The tabs display neatly, but fill unto the bottom of the screen, making the button invisible to the user. I already tried to move the code for the button directly between </FrameLayout> and </LinearLayout>, which didn't change anything. I also tried to move the code into the Frame Layout (directly beneath the final Scroll View), which resulted in the button being displayed directly in the tabs. Any help or ideas are appreciated.

Greets,
/tbi
A la fin, il y aura seulement de la beauté.
tbi
Junior Developer
Junior Developer
 
Posts: 12
Joined: Fri May 29, 2009 8:22 am
Location: Marburg, Germany

Top

Postby stifry » Thu Jun 18, 2009 7:58 am

Were you able to get the buttons at the bottom? I'm also having a problem with this.
Visit Trackaroo.com!
Trackmaster - Motorsports Lap Timer
Dynomaster - Performance Dyno
Image Image
User avatar
stifry
Developer
Developer
 
Posts: 46
Joined: Tue Feb 17, 2009 7:50 pm

Postby tbi » Thu Jun 18, 2009 12:38 pm

No, I had to implement it in the options menu. Admittedly, it does look nicer that way, but I'd still like a solution to this, just in case and for informational purposes.
Guys? Any idea?

Shrugging,
/tbi
A la fin, il y aura seulement de la beauté.
tbi
Junior Developer
Junior Developer
 
Posts: 12
Joined: Fri May 29, 2009 8:22 am
Location: Marburg, Germany

Postby stifry » Thu Jun 18, 2009 3:23 pm

Sounds like tabhost won't allow this:

Google Groups- Android Developers
Visit Trackaroo.com!
Trackmaster - Motorsports Lap Timer
Dynomaster - Performance Dyno
Image Image
User avatar
stifry
Developer
Developer
 
Posts: 46
Joined: Tue Feb 17, 2009 7:50 pm

Postby WarrenFaith » Fri Jun 19, 2009 8:08 am

WarrenFaith
Moderator
Moderator
 
Posts: 227
Joined: Fri Mar 13, 2009 10:59 am
Location: Berlin, Germany

Postby stifry » Fri Jun 19, 2009 3:57 pm

Thanks! This looks a lot better. Ideally, I want the scrollview to be in the tab (so the tabs stay at the top), but this is pretty close. Hopefully, they'll support scrolling inside the tab on a future release.

Image
Visit Trackaroo.com!
Trackmaster - Motorsports Lap Timer
Dynomaster - Performance Dyno
Image Image
User avatar
stifry
Developer
Developer
 
Posts: 46
Joined: Tue Feb 17, 2009 7:50 pm

Top

Tab button

Postby Dayn » Wed Jul 29, 2009 4:06 pm

Hi

I post a topic with button into a tab

please help me

my emulator donc like my xml even if its a simple xml like this

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<Button android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"/>

</LinearLayout>


I call xml file with mi java file with:

TabSpec ts1 = oTabHost.newTabSpec("tab1");
ts1.setIndicator("Voicemail");
ts1.setContent(new Intent(this, Tab1.class));
oTabHost.addTab(ts1);


in my Tab1 class, there is that: setContentView(R.layout.button); just that

but my android emulator have an error I think my xml file is wrong please

thanks

Dayn
User avatar
Dayn
Developer
Developer
 
Posts: 31
Joined: Thu Jul 09, 2009 10:45 am
Location: Paris and Dijon

Postby tbi » Thu Jul 30, 2009 9:54 am

Hey Dayn,

just three things:

You have noticed your layout XML doesn't include a TabHost? Might be the problem.
Take a look at my XML code (first post in this thread). Basically, you can c+p everything until the first ScrollView, then, instead of the three ScrollViews, put your LinearLayout containing the button there, and naturally, close the tags. Then you have a TabHost, a FrameLayout and everything you need to reference stuff from your Activity (which by the way should be a TabActivity).

I'm not sure if you can actually use setContent(Intent), and I'm also not sure what you're trying to accomplish there. If, what I assume, you want your Button to have an Intent, the way to go probably would be something like:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ((Button) getViewById(R.id.button)).setIntent(new Intent(...))
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Please, for the next posts, put your code in syntax tags. Makes it more readable.
Also, this tutorial might help you understanding TabLayouts/TabActivities.

Greets,
/tbi
A la fin, il y aura seulement de la beauté.
tbi
Junior Developer
Junior Developer
 
Posts: 12
Joined: Fri May 29, 2009 8:22 am
Location: Marburg, Germany

Postby Dayn » Thu Jul 30, 2009 11:55 am

thanks

I found my issu en then I forgot to add my new Tab1 class extend activity

so my xml files are:

*************** Tab *******************************

<?xml version="1.0" encoding="utf-8"?>

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TextView
android:id="@+id/textview2"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />

</FrameLayout>
</LinearLayout>
</TabHost>



**************** buttons ********************

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget235"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<Button
android:id="@+id/supprimer"
android:layout_width="100px"
android:layout_height="40px"
android:text="Supprimer"
android:textStyle="bold"
android:layout_x="180px"
android:layout_y="310px" >
</Button>

<Button
android:id="@+id/repondre"
android:layout_width="100px"
android:layout_height="40px"
android:text="Répondre"
android:textStyle="bold"
android:layout_x="42px"
android:layout_y="310px" >
</Button>

</AbsoluteLayout>


************** Androidmanifest.xml *********************

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="m.dany.anrdoid.inertfacegraphiquevvm"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">

<activity android:name=".InerfaceGraphiqueVVM"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".Tab1" android:label="Voicemail">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.SAMPLE_CODE"/>
</intent-filter>
</activity>

</application>
<uses-sdk android:minSdkVersion="3" />
</manifest>

thanks for your help !!
Attachments
Bouton_tab.JPG
Bouton_tab.JPG (27.94 KiB) Viewed 1598 times
Tab1.java
(339 Bytes) Downloaded 61 times
InerfaceGraphiqueVVM.java
(1.05 KiB) Downloaded 65 times
User avatar
Dayn
Developer
Developer
 
Posts: 31
Joined: Thu Jul 09, 2009 10:45 am
Location: Paris and Dijon

re

Postby Dayn » Thu Jul 30, 2009 12:02 pm

sorry I think its more readable

now
Attachments
Bouton_tab3.JPG
Bouton_tab3.JPG (57.77 KiB) Viewed 1596 times
Bouton_tab2.JPG
Bouton_tab2.JPG (52.24 KiB) Viewed 1596 times
User avatar
Dayn
Developer
Developer
 
Posts: 31
Joined: Thu Jul 09, 2009 10:45 am
Location: Paris and Dijon

Postby tbi » Thu Jul 30, 2009 2:11 pm

Pour le prochain fois, simplement entoure ton code des tags, comme
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ton code java
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
ou
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. ton code xml
Parsed in 0.000 seconds, using GeSHi 1.0.8.4
, pour le faire plus lisible, stp. Il ne faut pas faire une capture d'écran.

Greets,
/tbi

P.S.:
For those who don't speak French, I basically repeated the syntax tag thing from my last post (figures, probably).
A la fin, il y aura seulement de la beauté.
tbi
Junior Developer
Junior Developer
 
Posts: 12
Joined: Fri May 29, 2009 8:22 am
Location: Marburg, Germany

re

Postby Dayn » Thu Jul 30, 2009 3:21 pm

Ok thanks
Sorry about that !!

Dayn
User avatar
Dayn
Developer
Developer
 
Posts: 31
Joined: Thu Jul 09, 2009 10:45 am
Location: Paris and Dijon

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests