0
기본적으로이 대화 상자에는 전체 화면이며 진행률 막대 위에있는 단추가 있습니다 (단추를 클릭하면 사라지고 진행률 막대가 표시됨). 처음에는 XML을 액티비티에 포함 시켰고 모든 것이 예상대로 작동했지만 지금은 전체 화면 대화 상자로 리팩토링하려고합니다.DialogFragment의 RelativeLayout - MarginBottom이 무시됩니다.
문제 ProgressBar의 ontop이 있었다 버튼을 지금 특히 이상한 ProgressBar를이 버튼에 정렬되어 있다는 것입니다 무엇 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>
의 하단에 정렬,이지만, 여전히에 위치하고
여기는 자바 코드
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>
제거 : 'android : layout_alignParentBottom = "true"'Button ... – rafsanahmad007
에서 작동하지 않을 것입니다. 나는 부모의 바닥에 정렬하고 bottomMargin을 70 dips로 설정해야한다. – TormundThunderfist