Comment concevoir une mise en page de manière à ce qu'elle occupe l'espace du centre vers le bas d'une mise en page relative.
|--------------------------|
| |
| |
| |
| |
| |
|--------------------------|
| | |
| this will be |
| content |
| | |
| | |
|--------------------------|
<RelativeLayout>[another_layout should be here]</RelativeLayout>
alors un autre_layout commencera au milieu de RelativeLayout et se remplira jusqu'au bas de cette mise en page.
Réponses:
4 pour la réponse № 1Vous pouvez envelopper votre contenu dans une mise en page linéaire qui sera à l'intérieur de votre mise en page relative, puis définir android: layout_alignParentBottom = "true".
2 pour la réponse № 2
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- Invisible View that will hold the position -->
<View
android:id="@+id/stub"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerInParent="true"/>
<!-- Content below -->
<TextView
android:layout_below="@id/stub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="@string/something" />
</RelativeLayout>
0 pour la réponse № 3
Est-ce que RelativeLayout est votre élément de premier niveau? Si oui, pourquoi ne pas utiliser LinearLayout avec layout_weight
paramètres et ensuite faire juste le top un RelativeLayout
? Cela semble beaucoup plus logique que de le pirater au-dessous d’une vue que vous avez centrée. La disposition ressemblerait à quelque chose comme ça.
<LinearLayout
xmlns:android="stuff"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="1">
<!-- All the stuff that would have been above the center before -->
</RelativeLayout>
<RelativeLayout
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="1">
<!-- All the stuff that would have been below the center before -->
</RelativeLayout>
OMI qui est une solution plus propre