gpt4 book ai didi

android - 添加东西到 Android DialogFragment 的背景

转载 作者:太空狗 更新时间:2023-10-29 16:25:38 25 4
gpt4 key购买 nike

想在 Dialog 的背景中添加一些东西,比如

enter image description here

我试图阅读所有文档,但找不到将check in 文本添加到背景的方法。

最佳答案

我是这样弄的,希望对你有帮助

布局.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:calendar="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:id="@+id/mainLayout"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/fifty_five_dp"
android:background="@android:color/transparent"
android:orientation="vertical">

<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/twenty_dp"
android:layout_marginTop="@dimen/one_twenty_dp"
android:layout_marginRight="@dimen/twenty_dp"
calendar:cardCornerRadius="@dimen/three_dp"
calendar:cardElevation="@dimen/two_dp"
calendar:cardPreventCornerOverlap="true">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/fifty_five_dp"
android:background="@color/dull_white"
android:padding="@dimen/thirteen_dp"
android:textSize="@dimen/sixteen_sp">

<TextView
android:id="@+id/leaveFromTo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:fontFamily="@font/sf_pro_display_bold"
android:text="@string/select_leaves_placeholder"
android:textColor="@color/darkGreyDeepDeep"
android:textSize="@dimen/sixteen_sp" />

<TextView
android:id="@+id/leaveCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:fontFamily="@font/sf_pro_display_bold"
android:text="@string/days_placeholder"
android:textColor="@color/darkGrey"
android:textSize="@dimen/twelve_sp" />
</RelativeLayout>
</androidx.cardview.widget.CardView>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:calendar="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/seven_dp"
android:layout_marginTop="@dimen/fifteen_dp"

android:background="@drawable/box"
android:padding="@dimen/ten_dp">

<RelativeLayout
android:id="@+id/okayLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/thirteen_dp">

<ImageView
android:id="@+id/calenderDrawable"
android:layout_width="@dimen/seventeen_dp"
android:layout_height="@dimen/seventeen_dp"
android:layout_centerVertical="true"
android:src="@mipmap/calener" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="@dimen/ten_dp"
android:layout_toRightOf="@+id/calenderDrawable"
android:text="Calender"
android:textColor="@color/blue_light"
android:textSize="@dimen/fourteen_sp" />

<Button
android:id="@+id/btnDone"
android:layout_width="@dimen/seventy_dp"
android:layout_height="@dimen/twenty_six_dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_margin="@dimen/three_dp"
android:background="@drawable/calender_button_background"
android:text="DONE"
android:textColor="@color/white"
android:textSize="@dimen/thirteen_sp" />


</RelativeLayout>

<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/okayLayout"
android:layout_marginTop="@dimen/ten_dp"
android:background="@color/viewColor" />

<com.neomeric.nock.com.andexert.calendarlistview.library.DayPickerView
android:id="@+id/pickerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/view"
android:layout_marginTop="@dimen/ten_dp"
android:background="@color/dull_white"
calendar:enablePreviousDay="false" />

</RelativeLayout>

</LinearLayout>

DatePickerPopup.java

    public class DatePickerPopup extends DialogFragment implements DatePickerController {
private DayPickerView dayPickerView;

public DatePickerPopup() {
// Empty constructor is required for DialogFragment
// Make sure not to add arguments to the constructor
// Use `newInstance` instead as shown below
}

public static DatePickerPopup newInstance(OnDatesSelected datesSelected, Date first, Date last) {
DatePickerPopup frag = new DatePickerPopup();
Bundle args = new Bundle();
frag.setArguments(args);
return frag;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.date_selection_layout, container);
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

return root;
}

public void setDateAndDaysCount(SimpleMonthAdapter.SelectedDays<SimpleMonthAdapter.CalendarDay> selectedDays) {

}

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

}

@Override
public int getMaxYear() {
return 2021;
}

@Override
public void onDayOfMonthSelected(int year, int month, int day) {


}

@Override
public void onStart() {
super.onStart();
// To make it match parent
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

}

@Override
public void onDateRangeSelected(SimpleMonthAdapter.SelectedDays<SimpleMonthAdapter.CalendarDay> selectedDays) {

}

}

How it looks

关于android - 添加东西到 Android DialogFragment 的背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56007258/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com