這裏的一半地方的LinearLayout是我的應用程序:安卓:在高度
我想放置的LinearLayout(藍色)在屏幕的中間。 (事實上高度的一半)。
我不知道該怎麼做。
這裏是我的代碼:
<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="match_parent"
android:background="#E9E9E9"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin" >
<TextView
android:id="@+id/txt_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:text="title app"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="70sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="230dp"
android:background="@color/blue_dark_normal"
android:layout_centerVertical="true"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="15dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:orientation="vertical" >
<Button
android:id="@+id/startact_btn_connect"
style="?android:attr/borderlessButtonStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/bg_blue_button_login"
android:text="Se connecter"
android:textColor="@color/blanc" />
<View
android:layout_width="fill_parent"
android:layout_height="3dp"
android:layout_marginBottom="10dp"
android:background="@color/blue_pressed" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="5dp"
android:layout_marginRight="15dp"
android:layout_weight="1"
android:orientation="vertical" >
<Button
android:id="@+id/startact_btn_view_annonces"
style="?android:attr/borderlessButtonStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/bg_blue_dark_button_login"
android:text="Voir les annonces"
android:textColor="@color/blanc" />
<View
android:layout_width="fill_parent"
android:layout_height="3dp"
android:layout_marginBottom="10dp"
android:background="@color/blue_dark_pressed" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
這似乎不符合「一半高度」的要求,除非他知道確切的固定高度。 – Matt
正如我理解這個問題,視圖必須是父代高度的一半,而不是父代高度的一半。 –