我一直在搜索解決方案,我只找到解決方案,其中FrameLayout
或RelativeLayout
被使用,並且我正在使用LinearLayout
。Android - 如何設置以屏幕爲中心的前景圖像?
我想要做的是在頁面上加載一些內容之前,在前臺顯示一個圖片「請稍等」。我試圖讓圖片居中,而不是移動其他頁面元素......所以我想我需要它在前臺,對吧?
我該怎麼做?現在我有這個:
<ImageView
android:id="@+id/please_wait"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/please_wait"
android:foregroundGravity="center|fill_horizontal" />
但它不是居中形象,並沒有把它放在前臺。
這裏是整個XML文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<include android:id="@+id/header"
layout="@layout/header"
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
<ImageView
android:id="@+id/please_wait"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/please_wait"
android:foregroundGravity="center|fill_horizontal"
/>
<TextView
android:id="@+id/problem_loading_prompt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Getting the business(es) you are planning. They are stored in a database that is constantly backed up so you do not lose your work."
/>
<ListView
android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+id/label"
android:textSize="17sp">
</ListView>
<Button
android:id="@+id/add_problem_ok"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/light_best_blue"
android:text="Plan a New Business"
android:layout_marginTop ="15dp"
/>
</LinearLayout>
謝謝!
可以粘貼到整個xml文件pls。 –
@Rahmathullah M Pulikkal只是粘貼它 - 謝謝:) – Genadinik
所以其他組件將被加載時隱藏。對? –