I have a weird behavior I can\'t pinpoint the source of.
I have my app with the classic
requestWindowFeature(Window.FEATURE_NO_TITLE);
use,
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); //before
dialog.setContentView(R.layout.logindialog);
I'm using next variant:
Activity of my custom Dialog:
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 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:layout_width="300dp"
android:layout_height="wrap_content"
tools:context=".AlertDialogue">
<TextView
android:id="@+id/text_dialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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" />
<Button
android:id="@+id/button_dialog"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_margin="8dp"
android:background="@android:color/transparent"
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" />
</android.support.constraint.ConstraintLayout>
Manifest:
<activity android:name=".AlertDialogue"
android:theme="@style/AlertDialogNoTitle">
</activity>
Style:
<style name="AlertDialogNoTitle" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowNoTitle">true</item>
</style>
You can try this simple android dialog popup library. It is very simple to use on your activity.
When submit button is clicked try following code after including above lib in your code
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();
Add one line in your gradle and you good to go
dependencies {
compile 'com.vistrav:pop:2.0'
}
This worked for me.
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>
create your XML which is shown in dialog here it is 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();
You can also define Theme in android manifest file for not display Title bar..
You just define theme android:theme="@android:style/Theme.Light.NoTitleBar"
in activity where u dont want to display title bar
Example:-
<uses-sdk android:minSdkVersion="4"android:targetSdkVersion="4" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".splash"
android:label="@string/app_name" android:screenOrientation="portrait"
android:theme="@android:style/Theme.Light.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="main" android:screenOrientation="portrait" android:theme="@android:style/Theme.Light.NoTitleBar"></activity>