【发布时间】:2015-09-18 19:37:50
【问题描述】:
我有 DialogFragment,它显示了一些信息。它工作得很好,但我需要不同的标题,我需要白色标题颜色文本和标题的蓝色背景。 这是我的 xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"
android:id="@+id/icon_teacher"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/teacher"
android:id="@+id/teacher"
android:layout_marginLeft="10dp"
android:layout_alignTop="@+id/icon_teacher"
android:layout_toRightOf="@+id/icon_teacher"
android:layout_toEndOf="@+id/icon_teacher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/name_of_teacher"
android:textColor="@android:color/black"
android:textSize="16dp"
android:id="@+id/teacher_name"
android:layout_below="@+id/teacher"
android:layout_alignLeft="@+id/teacher"
android:layout_alignStart="@+id/teacher" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"
android:id="@+id/icon_time"
android:layout_below="@+id/icon_teacher"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/teacher"
android:id="@+id/time"
android:layout_marginLeft="10dp"
android:layout_alignTop="@+id/icon_time"
android:layout_toRightOf="@+id/icon_time"
android:layout_toEndOf="@+id/icon_time" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/name_of_teacher"
android:textColor="@android:color/black"
android:textSize="16dp"
android:id="@+id/time_name"
android:layout_below="@+id/time"
android:layout_alignLeft="@+id/time"
android:layout_alignStart="@+id/time" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"
android:id="@+id/icon_place"
android:layout_below="@+id/icon_time"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/teacher"
android:id="@+id/place"
android:layout_marginLeft="10dp"
android:layout_alignTop="@+id/icon_place"
android:layout_toRightOf="@+id/icon_place"
android:layout_toEndOf="@+id/icon_place" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/name_of_teacher"
android:textColor="@android:color/black"
android:textSize="16dp"
android:id="@+id/place_name"
android:layout_below="@+id/place"
android:layout_alignLeft="@+id/place"
android:layout_alignStart="@+id/place" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"
android:id="@+id/icon_home"
android:layout_below="@+id/icon_place"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/teacher"
android:id="@+id/home"
android:layout_marginLeft="10dp"
android:layout_alignTop="@+id/icon_home"
android:layout_toRightOf="@+id/icon_home"
android:layout_toEndOf="@+id/icon_home" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/name_of_teacher"
android:textColor="@android:color/black"
android:textSize="16dp"
android:id="@+id/place_home"
android:layout_below="@+id/home"
android:layout_alignLeft="@+id/home"
android:layout_alignStart="@+id/home" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:id="@+id/divider1"
android:layout_below="@+id/icon_home"
android:layout_marginTop="10dp"
android:background="@android:color/darker_gray"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/divider1"
android:layout_marginTop="10dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"
android:layout_marginLeft="10dp"
android:id="@+id/imageView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/alert"
android:id="@+id/alert"
android:layout_marginLeft="10dp"
android:layout_gravity="center_vertical"/>
</LinearLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
还有我的 DialogFragment,但我认为它不会有太大帮助:
public class LessonDialogFragment extends DialogFragment {
View view;
String title;
public LessonDialogFragment(String title) {
this.title = title;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.detail_dialog_fragment, container, false);
getDialog().setTitle(title);
return view;
}
}
我不知道怎么改,也许你能帮帮我。
【问题讨论】:
标签: android dialog fragment android-dialogfragment