2016-04-24 11 views
0

私は自分のプロジェクトの別のxmlファイルで作成したカスタムダイアログを使用していますが、メインウィンドウの色は青い灰色で、 ですが、メインヘッダーはデフォルトの白色のままです。アンドロイドスタジオのダイアログヘッダーをカスタマイズする方法は?

ヘッダーのフォントの色、サイズ、背景を変更する方法はありませんか?

私はヘッダーのテキストを変更することができますか?

のxml:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingLeft="15dp" 
    android:paddingRight="15dp" 
    android:background="#3edfbc" 
    android:orientation="vertical"> 


    <TextView 
     android:id="@+id/textaligmentManager_loader_textview" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textColor="#ffffff" 
     android:text="Initlizing Wifi" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

    <com.github.ybq.android.spinkit.SpinKitView xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/barcodeScanning_spinkit" 
     style="@style/SpinKitView.Large.FoldingCube" 
     android:layout_width="80dp" 
     android:layout_height="80dp" 
     android:layout_below="@+id/textaligmentManager_loader_textview" 
     android:padding="20dp" 
     android:layout_centerHorizontal="true" 
     app:SpinKit_Color="#ffffff" /> 


</RelativeLayout> 

ダイアログ:

Dialog dialog = new Dialog(Scanning_Barcode_Activity.this); 
     dialog.setContentView(R.layout.aligment_manager_loader_layout); 
     dialog.setTitle("Loading"); 
     dialog.setCancelable(false); 

     //set up text 
     loaderScreenMainText = (TextView) dialog.findViewById(R.id.textaligmentManager_loader_textview); 
     loaderScreenMainText.setText("Loading Wifi"); 


     //progressBar = (ProgressBar) dialog.findViewById(R.id.barcodeScanning_spinkit); 
     //DoubleBounce doubleBounce = new DoubleBounce(); 
     //progressBar.setIndeterminateDrawable(doubleBounce); 


     //now that the dialog is set up, it's time to show it 
     dialog.show(); 

答えて

0

レイアウト自体は、ヘッダ部分を含むようにカスタムレイアウトを設計します。そして、このコードをスキップ:

dialog.setTitle("Loading"); 

は、代わりにこのステートメントを追加します。

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 

またAlertDialogを使用することができます。この場合、requestWindowFeature()メソッドは必要ありません。

android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(Scanning_Barcode_Activity.this); 
LayoutInflater inflater = LayoutInflater.from(Scanning_Barcode_Activity.this); 
View customView = inflater.inflate(your_layout, null); 
builder.setCancelable(false); 
loaderScreenMainText = (TextView) customView.findViewById(R.id.textaligmentManager_loader_textview); 
loaderScreenMainText.setText("Loading Wifi"); 
builder.setView(customView); 
AlertDialog dialog = builder.create(); 
dialog.show(); 
+0

まだタイトル領域が表示されます...テキストなし...まだ画面に白い領域が表示されています。 –

+0

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); –

+0

この段階では、この段階でこれを行うことはできません。作成のビューにコンテンツが既に設定されているため(これは機能しません)... –

0

あなたはダイアログクラスのサブクラスであるAlertDialogを使用することができます。ここでは、タイトル、ボディ、ボタンなどのすべてを含むカスタムレイアウトを定義できます。余分なタイトルセクションは表示されません。ここにデモがあります:

AlertDialog.Builder builder = new AlertDialog.Builder(Scanning_Barcode_Activity.this); 
    builder.setCancelable(false); 
    LayoutInflater inflater = LayoutInflater.from(Scanning_Barcode_Activity.this); 
    View dialogView = inflater.inflate(R.layout.aligment_manager_loader_layout, null); 
    TextView loaderScreenMainText = (TextView) dialogView.findViewById(R.id.textaligmentManager_loader_textview); 
    loaderScreenMainText.setText("Loading Wifi"); 
    builder.setView(dialogView); 
    AlertDialog dialog = builder.create(); 
    dialog.show(); 
0

ヘッダーパーツのカスタマイズに使用できるスタイリッシュなオープンソースライブラリがたくさんあります。

ここで私は私の新しく開発されたオープンソースのライブラリを共有しています:PanterDialog

は、それはあなたを助けることを願っています。

関連する問題