一、RK芯片安卓平板、AOSP系统
二、修改原因:客户需求,蓝牙分享界面的搜索刷新图标太小,不明显
三、问题定位
首先通过adb install安装ES文件浏览器,再使用里面的文件分享功能,调出蓝牙共享界面;
调出界面后使用如下指令,获取当前activity;
adb shell
dumpsys window displays | grep mCurrentFocus
获取到的activity是
com.android.settings.bluetooth.DevicePickerActivity
相关代码路径为
packages\apps\Settings\src\com\android\settings\bluetooth\DevicePickerActivity.java
代码内容为:
public final class DevicePickerActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bluetooth_device_picker);
}
}
只有一个onCreate的方法,再看一下bluetooth_device_picker.xml的内容:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<fragment android:id="@+id/bluetooth_fragment_settings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
class="com.android.settings.bluetooth.DevicePickerFragment" />
</LinearLayout>
布局文件里只有一个fragment,界面的UI都是在DevicePickerFragment绘制的:
packages\apps\Settings\src\com\android\settings\bluetooth\DevicePickerFragment.java
在DevicePickerFragment.java中,有BluetoothProgressCategory类的实现,如下:
@VisibleForTesting
BluetoothProgressCategory mAvailableDevicesCategory;
mAvailableDevicesCategory = (BluetoothProgressCategory) findPreference(KEY_BT_DEVICE_LIST);
mAvailableDevicesCategory.setProgress(mLocalAdapter.isDiscovering());
mAvailableDevicesCategory.setProgress(started);
查看BluetoothProgressCategory.java
packages\apps\Settings\src\com\android\settings\bluetooth\BluetoothProgressCategory.java
public class BluetoothProgressCategory extends ProgressCategory {
public BluetoothProgressCategory(Context context) {
super(context);
init();
}
public BluetoothProgressCategory(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public BluetoothProgressCategory(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
public BluetoothProgressCategory(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init();
}
private void init() {
setEmptyTextRes(R.string.bluetooth_no_devices_found);
}
}
继承了ProgressCategory.java,再看下这个类
packages\apps\Settings\src\com\android\settings\ProgressCategory.java
public ProgressCategory(Context context) {
super(context);
setLayoutResource(R.layout.preference_progress_category);
}
public ProgressCategory(Context context, AttributeSet attrs) {
super(context, attrs);
setLayoutResource(R.layout.preference_progress_category);
}
public ProgressCategory(Context context, AttributeSet attrs,
int defStyleAttr) {
super(context, attrs, defStyleAttr);
setLayoutResource(R.layout.preference_progress_category);
}
public ProgressCategory(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
setLayoutResource(R.layout.preference_progress_category);
}
看下setLayoutResource引用的preference_progress_category.xml
packages\apps\Settings\res\layout\preference_progress_category.xml
<!-- Layout used for ProgressCategory in bluetooth settings. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
<LinearLayout
android:id="@+id/icon_container"
android:layout_width="56dp"
android:layout_height="wrap_content"
android:gravity="start|center_vertical"
android:orientation="horizontal">
<com.android.internal.widget.PreferenceImageView
android:id="@android:id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="18dp"
android:maxHeight="18dp"/>
</LinearLayout>
<!-- This text view has the style of the list separator text view without the background and padding. -->
<TextView
android:id="@android:id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="start|center"
android:textAppearance="@android:style/TextAppearance.Material.Body2"
android:textColor="?android:attr/colorAccent"/>
<ProgressBar
android:id="@+id/scanning_progress"
style="?android:attr/progressBarStyleSmallTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="16dip"
android:minWidth="32dp"
android:text="@string/progress_scanning"/>
</LinearLayout>
蓝牙分享界面的搜索刷新图标就是ProgressBar这个布局组件了,将
android:layout_width="wrap_content" android:layout_height="wrap_content"
改为自己想要的大小即可。