Bonjour,
Je développe ma première application Android.
Ma vue principale est un RelativeLayout :
Jusque là tout fonctionne avec un menu en haut et bas avec entre les deux un content.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"> <android.application.TopBarView android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true"/> <android.application.BottomBarView android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true"/> <android.application.ContentView android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_above="@+id/bottomBarView" android:layout_below="@+id/topBarView" android:layout_alignParentBottom="true"/> </RelativeLayout>
Je souhaite créer le ContentView ( class ContentView extends LinearLayout ) directement dans le code :
Le soucis, c'est que le content ne se trouve plus entre le menu du haut et le menu du bas.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 public void onCreate(Bundle savedInstanceState) { super.onCreate( savedInstanceState ); setContentView( R.layout.main ); RelativeLayout view = ( RelativeLayout ) findViewById( R.id.mainView ); bottomBar = ( BottomBarView ) findViewById( R.id.bottomBarView ); topBar = ( TopBarView ) findViewById( R.id.topView ); content = new Content( getApplicationContext() ); RelativeLayout.LayoutParams listParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT ); listParams.addRule( RelativeLayout.ABOVE, topBar.getId() ); listParams.addRule( RelativeLayout.BELOW, bottomBar.getId() ); view.addView( content, listParams ); }
La vue principale ne prend pas en compte les paramètres RelativeLayout.ABOVE et RelativeLayout.BELOW. Le content se trouve en haut de la vue(sur le menu du haut).
Savez-vous pourquoi?
Merci.
Partager