2013-02-01 5 views
1

HoloColors 또는 Action Bar Style Generator과 같은 테마 생성기가있어 대화 상자 및 AlertDialogs 테마를 변경하는 데 도움이됩니까?앱의 모든 대화 상자의 사용자 정의 테마

내 응용 프로그램은 Holo 테마를 사용하며 EditTexts 및 Buttons와 같은보기 스타일을 변경할 수 있지만 대화 상자에 나타나면 변경되지 않습니다. 제목 아래에 파란색 선의 색상을 변경하고 싶습니다.

이 주제와 관련된 몇 가지 질문과 답변을 찾았지만 실제로는 가능하지 않다고합니다. 나는 그것이 가능하지 않다고 믿을 수 없다.

답변

0

적어도 AlertDialog의 경우 가능합니다. 여기 당신의 코드에서 어떤 점 (예를 들어 버튼 클릭)에서 호출되는 함수의 내 솔루션을 게시하고 화면상의 경고 대화 상자 자체 레이아웃을 만듭니다. 레이아웃은 일반적인 layout.xml이며, 필요. 나를 위해 완벽하게 작동합니다!

private void showAddUserGeneratedStationDialog() { 

     AlertDialog.Builder alertDialog = new AlertDialog.Builder(
       AmplifyActivity.this); 

     LayoutInflater inflater = getLayoutInflater(); 

      //inflate your layout.xml 
     alertDialog 
       .setView(inflater.inflate(R.layout.dialog_add_station, null)); 

      //show dialog over activity screen 
     final AlertDialog ad = alertDialog.show(); 

      //put actions to your ui-elements 
     Button cancelBtn = (Button) ad 
       .findViewById(R.id.list_user_generated_cancelBU); 
     cancelBtn.setOnClickListener(new OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       ad.cancel(); 
      } 
     }); 

     Button doneBtn = (Button) ad 
       .findViewById(R.id.list_user_generated_doneBU); 
     doneBtn.setOnClickListener(new OnClickListener() { 
      @Override 
      public void onClick(View v) { 
          //get sth from your layout f.e. some textInput 
       String stationUrl = ((TextView) ad 
         .findViewById(R.id.list_user_generated_stationURLInput)) 
         .getText().toString(); 

        // did some other things 

       ad.dismiss(); 

      } 
     }); 

    } 

내 layout.xml

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/list_user_generated_addStationDialog" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="#99000000" 
    android:clickable="true" 
    android:gravity="center" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="300dp" 
     android:layout_height="200dp" 
     android:padding="10dp" 
     android:background="#000" 
     android:orientation="vertical" > 

     <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" > 

      <Button 
       android:id="@+id/list_user_generated_cancelBU" 
       style="@style/ButtonStyle" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center|right" 
       android:text="@string/cancel" /> 

      <TextView 
       style="@style/AmplifyHeadlineElement" 
       android:layout_width="0dp" 
       android:layout_height="fill_parent" 
       android:layout_weight="1" 
       android:text="@string/list_userGenerated_addStation" /> 

      <Button 
       android:id="@+id/list_user_generated_doneBU" 
       style="@style/ButtonStyle" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center|right" 
       android:text="@string/done" /> 
     </LinearLayout> 

     <EditText 
      android:id="@+id/list_user_generated_stationURLInput" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="20dp" 
      android:layout_marginTop="10dp" 
      android:background="#FFF" 
      android:ems="10" 
      android:hint="@string/list_userGenerated_addUrlExample" 
      android:inputType="textNoSuggestions" > 
     </EditText> 

     <!-- MORE BUT I DELETED IT FOR BETTER OVERVIEW --> 
    </LinearLayout> 
</LinearLayout> 
관련 문제