2017-02-25 6 views
0

フラグメント要素を作成しましたが、ウィジェットをどこにでも配置することはできません。ウィジェットは左上の角度に固定されています。フラグメント上に配置できない要素

enter image description here

enter image description here

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    tools:context="layout.BlankFragment"> 

    <!-- TODO: Update blank fragment layout --> 

    <ProgressBar 
     style="?android:attr/progressBarStyle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/progressBar5" /> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:text="@string/hello_blank_fragment" /> 

    <ProgressBar 
     style="?android:attr/progressBarStyle" 
     android:layout_width="282dp" 
     android:layout_height="259dp" 
     android:id="@+id/progressBar4" /> 

</FrameLayout> 

なぜこの問題?これは私の最初のAndroidアプリケーションですが、通常のアクティビティを使用している場合は、そのポジションが機能します。

+0

あなたのXMLを共有できます – AtaerCaner

+0

はい、投稿されたXML =) – user3477026

答えて

0

セットandroid:layout_gravity。たとえば、あなたがそれを中央にしたい場合:

<ProgressBar 
    style="?android:attr/progressBarStyle" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:id="@+id/progressBar5" /> 

あなたは他の上に子供をスタックFrameLayoutを使用しています。これがあなたの望むものでない場合は、LinearLayoutまたはRelativeLayoutの使用を検討してください。

+0

ありがとう、RelativeLayoutは私の問題を解決します=) – user3477026

関連する問題