我需要更改微调器弹出窗口的颜色.这是我到目前为止所尝试的: java代码:
ArrayAdapter<Integer> adapter_year = new ArrayAdapter<Integer>(this, R.drawable.custom_spinner_holidays, year);
adapter_year.setDropDownViewResource(R.layout.customize_spinner);
Run Code Online (Sandbox Code Playgroud)
custom_spinner_holidays.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="@drawable/custom_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@android:color/white" />
Run Code Online (Sandbox Code Playgroud)
customize_spinner.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/spinnertext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#0193DE"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
但它不起作用.当我点击微调器时,我收到错误.
由于我的弹出背景为白色,我需要更改微调器分隔符的颜色.我已尝试以下列方式设置微调器的样式,但它不起作用:
styles.xml
<style name="applicationTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:dropDownListViewStyle">@style/SpinnerStyle</item>
</style>
<style name="SpinnerStyle" parent="android:Widget.ListView.DropDown">
<item name="android:divider">#0193DE</item>
<item name="android:dividerHeight">1dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
主要的xml
<Spinner
android:id="@+id/year"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:background="@drawable/apptheme_spinner_default_holo_dark"
android:layout_marginLeft="75dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:spinnerMode="dropdown"
style="@style/SpinnerStyle"
android:popupBackground="#FFFFFF" />
Run Code Online (Sandbox Code Playgroud)
java的
ArrayAdapter<Integer> adapter_year = new ArrayAdapter<Integer>(this, R.drawable.custom_spinner_holidays, year);
adapter_year.setDropDownViewResource(R.layout.custom_spinner_popup);
Run Code Online (Sandbox Code Playgroud)
custom_spinner_holidays.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerItemStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@android:color/white" />
Run Code Online (Sandbox Code Playgroud)
custom_spinner_popup
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:ellipsize="marquee"
android:singleLine="true"
android:textColor="#0193DE" />
Run Code Online (Sandbox Code Playgroud)
我可以将所有这些合并为一个吗?

我正在尝试将自定义图标用于 ExpandableListView 的组展开和折叠状态。但这似乎不起作用。即使输出消息按顺序工作,图标也不会改变。
explistView.setOnGroupClickListener(new OnGroupClickListener()
{
@Override
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id)
{
groupIndicator = (ImageView) findViewById(R.id.group_indicator);
if (parent.isGroupExpanded(groupPosition))
{
System.out.println("1");
parent.collapseGroup(groupPosition);
System.out.println("2");
groupIndicator.setImageResource(R.drawable.expand_icon_35x35);
System.out.println("3");
adapter.notifyDataSetChanged();
}
else
{
System.out.println("4");
parent.expandGroup(groupPosition);
System.out.println("5");
groupIndicator.setImageResource(R.drawable.collapse_icon_35x35);
System.out.println("6");
adapter.notifyDataSetChanged();
}
return true;
}
});
Run Code Online (Sandbox Code Playgroud) 在这个xml中我试图显示7个ImageView,因此我使用的是ScrollView.但是,在模拟器中它不会完全显示第一个ImageView.只显示其下半部分.我该如何解决这个问题?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/homescreen_bg">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical" >
<ImageView
android:id="@+id/header"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/Homescreen_header"
android:src="@drawable/logoheader" />
<ImageView
android:id="@+id/empinfo_logo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dp"
android:contentDescription="@string/Homescreen_emp_info"
android:src="@drawable/employee_info" />
<ImageView
android:id="@+id/leaveinfo_logo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dp"
android:contentDescription="@string/Homescreen_leave_info"
android:src="@drawable/leave_info" />
<ImageView
android:id="@+id/holidays_logo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dp"
android:contentDescription="@string/Homescreen_holidays"
android:src="@drawable/holidays" />
<ImageView
android:id="@+id/leavereq_logo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dp"
android:contentDescription="@string/Homescreen_leave_req"
android:src="@drawable/leave_request" />
<ImageView
android:id="@+id/leavestatus_logo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dp"
android:contentDescription="@string/Homescreen_leave_status"
android:src="@drawable/leave_status" />
<ImageView
android:id="@+id/logout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dp"
android:contentDescription="@string/logout_button"
android:src="@drawable/logout" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)