J'ai une disposition linéaire simple et je veux diviser l'écran en deux parties de taille égale.Ajuster la taille de la mise en page parent
Dans le supérieur, je veux mettre un SurfaceView
qui a exactement la même taille que son parent, c'est-à-dire la moitié de l'écran. Malheureusement, il faut toujours soit prendre tout l'écran ou rien (selon la configuration). Pourquoi est-ce et comment puis-je le changer?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:orientation="vertical">
<LinearLayout android:id="@+id/layoutUpperDaw"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#192832">
<com.example.MySurvfaceView
android:id="@+id/id_mySurfaceView"
android:layout_width="match_parent"
android:layout_height="0pt"
android:layout_weight="1"
OR
android:layout_height="match_parent"
>
</com.example.MySurvfaceView>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#193222">
...
</LinearLayout>
</LinearLayout>
Ne fonctionne pas pour moi. Le 'MySurfaceView' n'est pas visible alors. – user1225905
@ user1225905 Voir la mise à jour – Sharj
Ok, l'approche sans le premier interne imbriqué 'LinearLayout' fonctionne, mais je ne suis pas sûr d'avoir la logique derrière le LinearLayout. Quand j'ajoute un 'LinearLayout' avec' weight = 1' et 'height = 0' autour de' MySurvfaceView' ça ne marche pas. – user1225905