AlertDialog 源码布局调整

来源:互联网 发布:mac硬件温度检测 编辑:程序博客网 时间:2024/05/24 07:18
 AlertDialog 统一修改 布局样式。首先要找到底层布局文件,\frameworks\base\core\res\res\layout  下 alert_dialog_material.xml  
<LinearLayout   .......                <TextView                    android:id="@+id/message"                    android:layout_width="match_parent"                    android:layout_height="wrap_content"                    android:paddingEnd="?attr/dialogPreferredPadding"                    android:paddingStart="?attr/dialogPreferredPadding"                    android:fontFamily="@string/font_family_subhead_material"                    android:textColor="?attr/textColorPrimary"                    android:textSize="30dp"                    />             .......    <include layout="@layout/alert_dialog_button_bar_material" /></LinearLayout>

修改alert_dialog_button_bar_material

<?xml version="1.0" encoding="utf-8"?><!--     Copyright (C) 2014 The Android Open Source Project     Licensed under the Apache License, Version 2.0 (the "License");     you may not use this file except in compliance with the License.     You may obtain a copy of the License at          http://www.apache.org/licenses/LICENSE-2.0     Unless required by applicable law or agreed to in writing, software     distributed under the License is distributed on an "AS IS" BASIS,     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.     See the License for the specific language governing permissions and     limitations under the License.--><com.android.internal.widget.ButtonBarLayout   ......    <Button        android:id="@+id/button3"        style="?attr/buttonBarNeutralButtonStyle"        android:layout_width="wrap_content"        android:layout_height="wrap_content" />    <Space        android:id="@+id/spacer"        android:layout_width="0dp"        android:layout_height="0dp"        android:layout_weight="0"        android:visibility="gone" />    <Button        android:id="@+id/button2"       android:layout_weight="1"        android:layout_width="0dp"        android:textSize="30dp"        android:layout_height="wrap_content" />    <Button        android:id="@+id/button1"        android:layout_weight="1"        android:layout_width="0dp"         android:textSize="30dp"        android:layout_height="wrap_content" /></com.android.internal.widget.ButtonBarLayout>

调整后布局如图

这里写图片描述

0 0
原创粉丝点击