2016-04-10 18 views
0

私はImageViewをイメージの背景とし、同時にプリローダーを画面の中央に縦横に並べます。私はprogressBarを中心に置くことができましたが、マージンを使ってわずかに上にオフセットすることはできませんでした。RelativeLayoutを使用して、中央揃えのProgressBarビューをオフセットしますか?

一部の人々は...私が背景となりrelativeLayoutとしての私のイメージを適用する必要があるとして、しかし、それは私のために動作しません、android:layout_weightを使用してと制御のLinearLayout を使用することが提案

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:gravity="center" 
      android:background="#FE6869" 
      android:weightSum="1"> 

<ImageView 
    android:src="@drawable/splashscreen" 
    android:scaleType="centerCrop" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 


<ProgressBar 
    android:id="@+id/loading_spinner" 
    style="@style/Widget.AppCompat.ProgressBar" 
    android:layout_width="65dp" 
    android:layout_height="65dp" 
    android:layout_centerVertical="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="170dp" /> 


</RelativeLayout > 
+0

何をしますか? –

+0

プログレスバーを水平方向に中央と垂直の両方に揃えたいが、プログレスバーをセンターに対してわずかに上/下に配置できるようにしたい。 –

答えて

1

これを試して。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:gravity="center" 
      android:background="#FE6869" 
      android:weightSum="1"> 

<ImageView 
    android:src="@drawable/splashscreen" 
    android:scaleType="centerCrop" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

<LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 
<ProgressBar 
    android:id="@+id/loading_spinner" 
    style="@style/Widget.AppCompat.ProgressBar" 
    android:layout_width="65dp" 
    android:layout_height="65dp" 
    android:layout_weight="1" 
    android:layout_marginTop="170dp" /> 
</LinearLayout> 
</RelativeLayout > 
+0

ありがとう、あなたが作成したネストされたレイアウトを使用して位置決めを行うことができました。 –

関連する問題