DialogFragment在Android 4.4.2中有蓝线 [英] DialogFragment has blue line on top in Android 4.4.2
本文介绍了DialogFragment在Android 4.4.2中有蓝线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的对话框片段顶部出现一条蓝线,我无法摆脱(I甚至不知道它为什么会出现在第一位。有没有人知道如何摆脱这个?
There's a blue line appearing on top of my dialog fragment that I can't get rid off(I don't even know why does it appear in the first place. Does anybody know on how to get rid of this?
我在几台设备上测试了它的确有效在以后的Android版本上就好了。
I have tested it on several devices and it works just fine on later Android versions.
我的代码:
private void setupDialog() {
final Dialog dialog = getDialog();
final Window window = dialog.getWindow();
window.setBackgroundDrawable(new ColorDrawable(0));
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tiktok="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/settings_bg">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
<ImageView
android:id="@+id/close_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_margin="15dp"
android:src="@drawable/pressable_close_btn"/>
<com.cyscorpions.timekeeper.customviews.TKTextView
android:id="@+id/settings_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dp_40"
android:text="@string/settings_allcaps"
android:textColor="@color/timekeeper_blue"
android:textSize="@dimen/sp_60"
tiktok:useBoldFont="true"/>
<com.cyscorpions.timekeeper.customviews.TKTextView
android:id="@+id/account_name_instruction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/settings_title"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dp_20"
android:text="@string/subdomain_instruction"
android:textColor="@color/gray"
android:textSize="@dimen/sp_30"/>
<RelativeLayout
android:id="@+id/info_field"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_70"
android:layout_alignLeft="@+id/submit_btn"
android:layout_below="@id/account_name_instruction"
android:layout_centerHorizontal="true"
android:layout_marginLeft="2dp"
android:layout_marginTop="@dimen/dp_20">
<com.cyscorpions.timekeeper.customviews.TKAppCompatEditText
android:id="@+id/subdomain_textfield"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="@drawable/text_field_bg"
android:hint="@string/textfield_account_hint"
android:inputType="text"
android:textColor="@color/gray"
android:textColorHint="@color/gray"
android:textSize="@dimen/sp_20"
tiktok:setTextFieldFont="@string/montserrat_reg"/>
<com.cyscorpions.timekeeper.customviews.TKTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/subdomain_textfield"
android:text="@string/domain_suffix"
android:textColor="@color/gray"
android:textSize="@dimen/sp_25"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/error_tooltip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/settings_title">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/error_tooltip"
android:shadowColor="@color/black"/>
<com.cyscorpions.timekeeper.customviews.TKTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dp_20"
android:text="@string/field_required"
android:textColor="@color/white"
android:textSize="@dimen/sp_30"/>
</RelativeLayout>
<com.cyscorpions.timekeeper.customviews.TKButton
android:id="@id/submit_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/info_field"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dp_10"
android:background="@drawable/pressable_submit_btn"
android:text="@string/submit_allcaps"
android:textColor="@color/white"
android:textSize="@dimen/sp_30"
tiktok:hasDarkerPressedState="true"
tiktok:useDefaultDrawable="true"/>
</RelativeLayout>
</RelativeLayout>
推荐答案
我想当它还有一个标题栏时会出现。我只是隐藏了标题栏,它工作得很好..
I guess it appears when there is still a title bar. I just hid the title bar and it works just fine..
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
这篇关于DialogFragment在Android 4.4.2中有蓝线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文