比较来自世界各地的卖家的域名和 IT 服务价格

Android 对话框:删除标题字符串

我有一个奇怪的行为,其来源无法准确地确定。

我有我的申请经典


requestWindowFeature/Window.FEATURE_NO_TITLE/;


删除标题字符串 / 地位。

然后我创建一个对话框,允许用户输入信息 /名称等/

物理键盘没有问题,但是当我使用虚拟键盘时,我有一个奇怪的行为:

每次我按虚拟键盘上的键,标题字符串/通过移动整个键盘布局,再次出现状态,然后再次消失。 /就像启动应用程序时一样喜欢动画/

这是某种代码 :


dialog = new Dialog/context/;
dialog.setContentView/R.layout.logindialog/;
dialog.setTitle/"Login:"/;

WindowManager.LayoutParams a = dialog.getWindow//.getAttributes//;

// dialog.requestWindowFeature/Window.FEATURE_NO_TITLE/;

a.dimAmount = 0;
dialog.getWindow//.setAttributes/a/;

dialog.setCancelable/true/;
dialog.getWindow//.setLayout/LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT/;


进而


dialog.show//;


我试过了


dialog.requestWindowFeature/Window.FEATURE_NO_TITLE/;


但这会导致我的申请失败。

这个 xml



<textview android:gravity="fill" android:id="@+id/LoginText" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Login:">
</textview>
<edittext android:id="@+id/LoginEdit" android:layout_height="wrap_content" android:layout_width="200sp" android:singleline="true" android:text="jason"></edittext>
<textview android:id="@+id/PasswordText" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Password:">
</textview>
<edittext android:id="@+id/PasswordEdit" android:layout_height="wrap_content" android:layout_width="200sp" android:password="true" android:singleline="true" android:text="welcome"></edittext>
<linearlayout android:gravity="center_horizontal" android:id="@+id/test2" android:layout_height="wrap_content" android:layout_width="wrap_content" android:orientation="horizontal">
<button android:id="@+id/LoginButton" android:layout_centerhorizontal="true" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Login"></button>
<button android:id="@+id/CreateButton" android:layout_centerhorizontal="true" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Create"></button>
<button android:id="@+id/CancelLogin" android:layout_centerhorizontal="true" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Cancel"></button>
</linearlayout>/>
已邀请:

龙天

赞同来自:

采用,


dialog.requestWindowFeature/Window.FEATURE_NO_TITLE/; //before 
dialog.setContentView/R.layout.logindialog/;

快网

赞同来自:

创造一个新的风格 styles.xml


<style name="myDialog" parent="android:style/Theme.Dialog">
<item name="android:windowNoTitle">true</item>
</style>


然后将其添加到清单:


<activity android:name=".youractivity" android:theme="@style/myDialog"></activity>

奔跑吧少年

赞同来自:

上述所有答案都不适合我 AppCompatDialog

如果您正在使用

AppCompatDialog

试试吧

重要的提示:

在调用之前设置此值。 setContentView.

dialog.supportRequestWindowFeature/Window.FEATURE_NO_TITLE/;

董宝中

赞同来自:

创造自己的 XML 这在对话中显示
这里是 activity_no_title_dialog


final Dialog dialog1 = new Dialog/context/;
dialog1.requestWindowFeature/Window.FEATURE_NO_TITLE/;
dialog1.setContentView/R.layout.activity_no_title_dialog/;
dialog1.show//;

董宝中

赞同来自:

您还可以在清单文件中定义主题。 android 因为没有显示标题字符串..

你只是定义了这个话题
android:theme="@android:style/Theme.Light.NoTitleBar"

在您不想显示标题字符串的行动中

例子

:-


<uses-sdk android:minsdkversion="4" android:targetsdkversion="4"></uses-sdk>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:label="@string/app_name" android:name=".splash" android:screenorientation="portrait" android:theme="@android:style/Theme.Light.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"></action>
<category android:name="android.intent.category.LAUNCHER"></category>
</intent-filter>
</activity>
<activity android:name="main" android:screenorientation="portrait" android:theme="@android:style/Theme.Light.NoTitleBar"></activity>


</application>

董宝中

赞同来自:

如果使用自定义表示,请不要忘记在添加内容以读取之前请求窗口函数如下。


dialog.requestWindowFeature/Window.FEATURE_NO_TITLE/;
dialog.setContentView/view/;
dialog.show//;

奔跑吧少年

赞同来自:

之前使用下面的代码 setcontentview :-


dialog.requestWindowFeature/Window.FEATURE_NO_TITLE/; 
dialog.setContentView/R.layout.custom_dialog/;


笔记: -

上面的代码应该在上面使用。
dialog.setContentView/R.layout.custom_dialog/;


在 XML 使用主题


android:theme="@android:style/Theme.NoTitleBar"


还 styles.xml

:


<style name="hidetitle" parent="android:style/Theme.Dialog">
<item name="android:windowNoTitle">true</item>
</style>


进而:


Dialog dialog_hidetitle_example = new Dialog/context, R.style.hidetitle/;

石油百科

赞同来自:

我是新手 Android 我遇到了这个问题,试图摆脱标题字符串。

我使用动作并以对话的形式显示它。 我敲了主题,遇到了默认主题的有用部分。

这是我的代码
AndroidManifest.xml

, 显示标题字符串显示的情况下:


<activity android:name=".AlertDialog" android:theme="@android:style/Theme.Holo.Dialog">
</activity>


这是一个让我带来所需结果的更改:


<activity android:name=".AlertDialog" android:theme="@android:style/Theme.Holo.Dialog.NoActionBar">
</activity>


正如我所说,我还是新的 Android, 因此它可以具有不必要的副作用,但似乎它给了我所需的结果,这只是为了从对话框中删除标题字符串。

三叔

赞同来自:

使用下一个选项,我没有反应:


dialog.requestWindowFeature/Window.FEATURE_NO_TITLE/; //before 
dialog.setContentView/R.layout.logindialog/;


所以,我尝试使用以下内容:


dialog.supportRequestWindowFeature/Window.FEATURE_NO_TITLE/; //before 
dialog.setContentView/R.layout.logindialog/;


此选项可以正常工作。

快网

赞同来自:

我使用以下选项:

我的用户对话的活动

:


public class AlertDialogue extends AppCompatActivity {

Button btnOk;
TextView textDialog;

@Override
protected void onCreate/Bundle savedInstanceState/ {
super.onCreate/savedInstanceState/;
supportRequestWindowFeature/Window.FEATURE_NO_TITLE/;
setContentView/R.layout.activity_alert_dialogue/;

textDialog = /TextView/findViewById/R.id.text_dialog/ ;
textDialog.setText/"Hello, I'm the dialog text!"/;

btnOk = /Button/ findViewById/R.id.button_dialog/;
btnOk.setOnClickListener/new View.OnClickListener// {
@Override
public void onClick/View v/ {
finish//;
}
}/;
}
}


activity_alert_dialogue.xml

:


xml version="1.0" encoding="utf-8"?
<android.support.constraint.constraintlayout android:layout_height="wrap_content" android:layout_width="300dp" tools:context=".AlertDialogue" xmlns:android="[url=http://schemas.android.com/apk/res/android"]http://schemas.android.com/apk/res/android"[/url] xmlns:app="[url=http://schemas.android.com/apk/res-auto"]http://schemas.android.com/apk/res-auto"[/url] xmlns:tools="[url=http://schemas.android.com/tools">]http://schemas.android.com/tools">[/url]
<textview android:id="@+id/text_dialog" android:layout_height="wrap_content" android:layout_width="match_parent" android:padding="24dp" android:text="Hello, I'm the dialog text!" android:textcolor="@android:color/darker_gray" android:textsize="16dp" app:layout_constraintstart_tostartof="parent" app:layout_constrainttop_totopof="parent"></textview>
<button android:background="@android:color/transparent" android:id="@+id/button_dialog" android:layout_height="36dp" android:layout_margin="8dp" android:layout_width="wrap_content" android:text="Ok" android:textcolor="@android:color/black" android:textsize="14dp" app:layout_constraintbottom_tobottomof="parent" app:layout_constraintend_toendof="parent" app:layout_constrainttop_tobottomof="@+id/text_dialog"></button>
</android.support.constraint.constraintlayout>


宣言

:


<activity android:name=".AlertDialogue" android:theme="@style/AlertDialogNoTitle">
</activity>


风格

:


<style name="AlertDialogNoTitle" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowNoTitle">true</item>
</style>

喜特乐

赞同来自:

你可以尝试这个简单
https://github.com/00ec454/pop
窗户 android. 在您的活动中使用很容易。

按下“发送”按钮时,请在上面打开后尝试以下代码 lib 进入你的代码


Pop.on/this/
.with//
.title/R.string.title/ //ignore if not needed
.icon/R.drawable.icon/ //ignore if not needed
.cancelable/false/ //ignore if not needed
.layout/R.layout.custom_pop/
.when/new Pop.Yah// {
@Override
public void clicked/DialogInterface dialog, View view/ {
Toast.makeText/getBaseContext//, "Yah button clicked", Toast.LENGTH_LONG/.show//;
}
}/.show//;


为您添加一行 gradle 你顺利


dependencies {
compile 'com.vistrav:pop:2.0'
}

石油百科

赞同来自:

它为我工作。


Dailog dialog = new Dialog/MyActivity.this, R.style.dialogstyle/;

xml version="1.0" encoding="utf-8"?
<resources>
<style name="dialogstyle" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">@null</item>
<item name="android:windowNoTitle">false</item>
</style>
</resources>

喜特乐

赞同来自:

**write this before adding view to dialog.**


dialog1.requestWindowFeature/Window.FEATURE_NO_TITLE/;

要回复问题请先登录注册