2017-04-10 3 views
0

基本的に、このダイアログフラグはフルスクリーンで、プログレスバー上にボタンがあります(ボタンをクリックすると消えてプログレスバーが表示されます)。私は当初、xmlをアクティビティに持っていて、すべてが期待通りに機能しましたが、今度はそれをリファクタリングしてフルスクリーンのダイアログフラグメントにしたいと思います。DialogFragmentのRelativeLayout - MarginBottomは無視されます

問題は、プログレスバーの岩下たボタンは、現在、特に変な何parentLayout

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_gps_loading" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/bg_setsensor" 
    tools:ignore="MissingPrefix" 
    > 

    <ImageView 
     android:layout_width="90dp" 
     android:layout_height="38dp" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="45dp" 
     /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:layout_marginLeft="40dp" 
     android:layout_marginRight="40dp" 
     android:orientation="vertical" 
     > 

    <ImageView 
     android:layout_width="50dp" 
     android:layout_height="50dp" 
     android:layout_gravity="center_horizontal" 
     android:src="@drawable/ic_location" 
     /> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_gravity="center_horizontal" 
     android:layout_marginTop="17dp" 
     android:gravity="center_horizontal" 
     android:text="@string/promptGpsPermissionBody" 
     style="@style/fullscreenText" 
     /> 
    </LinearLayout> 

    <ProgressBar 
     android:id="@+id/progressBar2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/btnActivateGps" 
     android:layout_alignTop="@+id/btnActivateGps" 
     style="?android:attr/progressBarStyle" 
     /> 

    <Button 
     android:id="@+id/btnActivateGps" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginBottom="71dp" 
     android:layout_marginLeft="63dp" 
     android:layout_marginRight="63dp" 
     android:background="@color/white" 
     android:enabled="true" 
     android:visibility="visible" 
     /> 
</RelativeLayout> 

の下に整列されているプログレスバーがボタンに整列されていることですが、それはまだにありますここ

前と同じ位置には、Javaコード

public class GpsSensorDialog extends DialogFragment { 

    @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { 
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 
    LayoutInflater inflater = getActivity().getLayoutInflater(); 

    View view = inflater.inflate(R.layout.activity_gps_sensor, null); 

    builder.setView(view); 

    Dialog dialog = builder.create(); 

    if (dialog.getWindow() != null) { 
     dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); 
     dialog.getWindow() 
      .setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); 
    } 
    return dialog; 
    } 

    @Override public void onCreate(@Nullable Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setStyle(STYLE_NO_TITLE, R.style.CustomDialog); 
    } 

    public static GpsSensorDialog newInstance() { 
    Bundle args = new Bundle(); 
    GpsSensorDialog fragment = new GpsSensorDialog(); 
    fragment.setArguments(args); 
    return fragment; 
    } 

    @Override public void onStart() { 
    super.onStart(); 
    getDialog().getWindow() 
     .setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); 
    } 
} 

と私はのonCreate

012で設定するスタイルです
<style name="CustomDialog"> 
    <item name="android:windowFrame">@null</item> 
    <item name="android:windowIsFloating">true</item> 
    <item name="android:windowContentOverlay">@null</item> 
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item> 
    <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item> 
</style> 
+0

削除: 'android:layout_alignParentBottom = "true" 'ボタンから。 – rafsanahmad007

+0

は動作しません。私は親の底にそれを整列させ、bottomMarginを70ディップに設定しなければならない – TormundThunderfist

答えて

0

このレイアウトを試してください。また、それに応じてdrawable、スタイル、文字列を変更してください。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_gps_loading" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@mipmap/ic_launcher" 
    tools:ignore="MissingPrefix"> 

    <ImageView 
     android:layout_width="90dp" 
     android:layout_height="38dp" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="45dp" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:layout_marginLeft="40dp" 
     android:layout_marginRight="40dp" 
     android:orientation="vertical"> 

     <ImageView 
      android:layout_width="50dp" 
      android:layout_height="50dp" 
      android:layout_gravity="center_horizontal" 
      android:src="@mipmap/ic_launcher" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_gravity="center_horizontal" 
      android:layout_marginTop="17dp" 
      android:gravity="center_horizontal" 
      android:text="obsdas" /> 
    </LinearLayout> 

    <ProgressBar 
     android:id="@+id/progressBar2" 
     style="?android:attr/progressBarStyle" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/btnActivateGps" /> 

    <Button 
     android:id="@+id/btnActivateGps" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:layout_centerHorizontal="true" 
     android:layout_marginBottom="71dp" 
     android:layout_marginLeft="63dp" 
     android:layout_marginRight="63dp" 
     android:background="@android:color/white" 
     android:enabled="true" 
     android:visibility="visible" /> 
</RelativeLayout> 
関連する問題