Czy istnieje sposób na przesunięcie widoku z centrum na Androida?

Próbuję umieścić mój przycisk nie dokładnie w środku, ale powiedzmy, że w 2/5 wysokości ekranu szukałem atrybutu bezskutecznie, więc spróbowałem tego podejścia

<RelativeLayout 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="@drawable/background"
android:padding="20dp" >

 <ImageButton
    android:id="@+id/flashlight_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_above="@+id/fakeView"
    android:background="@null"
    android:contentDescription="@string/flashlight_button_description"
    android:src="@drawable/freeml_bright" />

   <View
    android:id="@+id/fakeView"
    android:layout_width="10dp"
    android:layout_height="10dp"
    android:layout_centerInParent="true"
    android:background="#FFAABB" />

</RelativeLayout>

jednak nie działa, nawet jeśli ustawię margines na fałszywym widoku.

Jakieś pomysły?

//EDYTOWAĆ//

dzięki za odpowiedzi chłopaki, atrybut dopełnienia działa, jednak ponieważ jest to duży obraz i jeśli chcę, aby zaczynał się od 2/5 wysokości ekranu, pokrywa on środkowy punkt ekranu, więc jeśli użyję atrybutu dopełnienia, to działa, ale to odpycha go od środka i nie pozwala na jego zakrycie. Przepraszam moja wina

Chociaż sprawiłem, że działał w układzie liniowym, którego chciałem uniknąć, ponieważ jest więcej widoków na górze i na dole obok siebie, co doprowadziłoby do zagnieżdżonych widoków przy użyciu układu liniowego. Niestety myślę, że to jedyna opcja.

Zasadniczo używa innego liniowego układu, który wypełnia pozostałą przestrzeń niewykorzystaną przez widoki górne i dolne o wysokości = 0dp i wadze = 1 i ustawia swoją grawitację na środek

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:contentDescription="@string/application_logo_description"
        android:src="@drawable/mylight" />

     <ImageButton
        android:id="@+id/settings_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:background="@null"
        android:contentDescription="@string/settings_button_description"
        android:src="@drawable/settings_button" /> 
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:gravity="center"
    android:orientation="vertical" >

    <ImageButton
        android:id="@+id/flashlight_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@null"
        android:contentDescription="@string/flashlight_button_description"
        android:src="@drawable/flashlight_button_selector" />

    <View
        android:id="@+id/fakeView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginTop="60dp"
        android:background="#FFAABB" />
</LinearLayout>

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|center_horizontal"
    android:contentDescription="@string/powered_by_description"
    android:src="@drawable/powered_by" />

<ImageButton
    android:id="@+id/ad_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|center_horizontal"
    android:background="@null"
    android:contentDescription="@string/ad_button_description"
    android:src="@drawable/freeml" />

 </LinearLayout>

Dzięki za wkład.

questionAnswers(3)

yourAnswerToTheQuestion