我正在制作一款需要在黑暗中轻松阅读的应用。默认情况下,屏幕是白色的,这对用户来说可能很难。用户开始使用的主要活动称为菜单,我希望它具有全黑的背景,带有白色文本。除了我的ListView,它看起来很黑,但我看不到文字,因为背景也是黑色的。
menu.xml文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#000000"
tools:context=".MainActivity" xmlns:app="http://schemas.android.com/apk/lib/com.google.ads">
<TextView
android:id="@+id/SelectSong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@android:id/list"
android:layout_alignTop="@+id/ic_launcher"
android:text="@string/SelectSong"
android:textSize="20sp"
android:textColor="#FFFFFF" />
<ListView
android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="320dp"
android:layout_above="@+id/settings_button"
android:layout_below="@+id/ic_launcher"
android:textColor="#FFFFFF"
tools:listitem="@android:layout/simple_list_item_1" >
</ListView>
<ImageView
android:id="@+id/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:contentDescription="@string/ic_launcher"
android:src="@drawable/ic_launcher" />
<ImageButton
android:id="@+id/settings_button"
android:src="@drawable/settings_button_selected"
android:contentDescription="@string/action_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" />
<ImageButton
android:id="@+id/exit_button"
android:src="@drawable/exit_button_selected"
android:contentDescription="@string/exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" />
</RelativeLayout>
Menu.java:
package com.lmarshall1995.scoutsongs;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.ListView;
public class Menu extends ListActivity{
String classes[] = {"......"};
String items[] = {"......"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
final ImageButton settings = (ImageButton) findViewById(R.id.settings_button);
settings.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
......
}
});
final ImageButton back = (ImageButton) findViewById(R.id.exit_button);
back.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
......
}
});
setListAdapter(new ArrayAdapter<String>(Menu.this, android.R.layout.simple_list_item_1, items));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
String song_activity = classes[position];
try{
Class<?> ourClass = Class.forName("com.lmarshall1995.scoutsongs." + song_activity);
Intent ourIntent = new Intent(Menu.this, ourClass);
startActivity(ourIntent);
}catch(ClassNotFoundException e){
e.printStackTrace();
}
}
}
有人可以告诉我如何更改代码以使其工作吗? - 我删除了任何不需要分享的代码,只需输入“......”。
谢谢你, 从 劳伦斯=]
答案 0 :(得分:0)
您可以在“列表”视图中添加深色背景。下载一个黑色的png图像并放在可绘制的文件夹中。例如show
android:background="@drawable/some_black_image"
<ListView
android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="320dp"
android:layout_above="@+id/settings_button"
android:layout_below="@+id/ic_launcher"
android:textColor="#FFFFFF"
android:background="@drawable/some_black_image"
tools:listitem="@android:layout/simple_list_item_1" >
</ListView>