2010-11-20 43 views
1

J'ai une linearlayout A contenant une vue image et scrollview. Le scrollview contient une deuxième linearlayout B L'idée est d'avoir un en-tête fixe tandis que le linearLayout B contient plusieurs vues qui correspondent exactement à la hauteur de la scrollview. Voyez-le comme une tabview où tous les onglets sont l'un après l'autre dans un scrollview.ScrollView hauteur 0 même lorsque fill_parent

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout android:id="@+id/main_view" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#000000" 
    android:orientation="vertical"> 

<ImageView android:id="@+id/logoImg" 
    android:layout_width="fill_parent" 
    android:gravity="center" 
    android:src="@drawable/logo" 
    android:layout_height="wrap_content"/> 

<ScrollView 
    android:id="@+id/scrollView" 
    android:layout_weight="1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

<LinearLayout android:id="@+id/scrollLinear" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 
</ScrollView> 
</LinearLayout> 

J'ai essayé d'y parvenir en appelant getHeight sur la ScrollView puis définissez cette hauteur à chaque vue dans le LinearLayout B mais getHeight retourne toujours 0. Toute une idée quelle est la meilleure façon d'y parvenir?

+0

Je suis désolé mais je ne comprends pas ... vous voulez l'équivalent d'un tabview vertical? pourquoi utiliser une scrollview alors? – Sephy

+0

Eh bien, je veux un onglet animé. Si vous cliquez sur un onglet, l'onglet correct est affiché en faisant défiler le scrollview vers la bonne position. Je pense que ça a l'air sympa. Je sais que je peux utiliser une tabview pour obtenir le même effet fonctionnel mais pas le même effet visuel. – Tin

Répondre

1

Eh bien, la question est très ancienne, mais je vais l'essayer :) Ne serait-ce pas le manque de "fillViewport" dans ScrollView?

<ScrollView 
    android:id="@+id/scrollView" 
    android:layout_weight="1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 

    android:fillViewport="true" 

    >