Je commencerais par mon objectif. Ce que je veux réaliser, c'est avoir une mise en page qui soit 3 fois plus grande que l'écran réel du téléphone.scrollview ne fait pas défiler la hauteur de réglage par programme
En ce moment j'essaie de tester ma solution, mais j'ai un problème avec le défilement. Voici comment regarder ma mise en page:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="400dp"
tools:context=".Zo"
android:id="@+id/zo_root"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="9">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="@color/Red"
></FrameLayout >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="@color/Yellow"
></FrameLayout >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="@color/Blue"
></FrameLayout >
</LinearLayout>
</ScrollView>
Mon code derrière:
@Override
protected void onCreate (Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zo);
setParameterForScroolView();
}
private void setParameterForScroolView()
{
ParameterKeeper parameterKeeper = new ParameterKeeper(this);
LinearLayout linearLayout = (LinearLayout)findViewById(R.id.zo_root);
linearLayout.getLayoutParams().height = parameterKeeper.getHeightOfScreen() *3;
}
Le code fonctionne bien derrière, parce que mon écran entier est rouge, mais je ne peux pas faire défiler du tout.
Il y avait answer qui a dit, que je dois retirer de scrollView
android:fillViewport="true"
. Après cela, mon LinearLayout diseapers comme dans this question.
J'ai ajouté LinearLayout en tant que root (source) mais cela ne m'a pas aidé du tout.
Avez-vous une idée la solution?
J'essaie aussi mis en place height
1600dp
400dp
pour Racine LinearLayout
dans xml
pour être sûr que ce n'est pas un problème recalcul view
. Ça ne marche pas aussi.
Je vais essayer aujourd'hui;) thx pour la réponse – MyWay
Et la hauteur pour la mise en page racine doit être définie comme match_parent? – MyWay
oui c'est vrai. – hasan83