我一直在努力让我PreferenceFragment拥有与我的应用程序其余部分相同的基于材质的主题和样式(通过AppCompat).在PreferenceFragment我使用管理我所有的应用程序设置如下图所示:

正如你可以从上面的截图中看到,我能够自定义PreferenceFragment使用colorAccent,colorPrimary和一些其他属性.我的主题PreferenceFragment如下:
<style
name="settingsTheme"
parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/blue_grey_500</item>
<item name="colorAccent">@color/blue_grey_500</item>
<item name="android:textColor">@color/black_text_alt</item>
<item name="android:textColorSecondary">@color/black_secondary_text</item>
</style>
Run Code Online (Sandbox Code Playgroud)
然而,尽管我付出了最大努力,但我无法将主题应用于我内部的各个元素PreferenceFragment,例如ListPreference和EditTextPreference; 所有首选项仍保留标准的AppCompat主题:

我发现一篇2年前的帖子讨论了这个问题,虽然没有真正的解决方案:如何将主题应用于<PreferenceScreen> <PreferenceCategory>元素
我想知道自从AppComat V21发布以来是否有人能够成功地将主题应用于首选项.如果没有,是否有任何可行的解决方法可用于将自定义主题应用于个人偏好?
我正在设计一个Android应用程序,并决定尝试新的Material主题.我在网上找到了新主题的所有可用颜色方案,但我无法找到具有调色板中所有颜色的相应.xml文件.有谁知道我在哪里可以找到这个,以便我可以在我的风格中使用这些颜色?以下是调色板:http://www.google.com/design/spec/style/color.html#color-ui-color-application
我正在开发一个我想要启用透明状态栏的应用程序.我想要一个ImageView(我的scaleType属性需要)覆盖整个屏幕,以便图像显示在状态栏下方.这是我的布局:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="@drawable/picture" />
<android.support.v7.widget.Toolbar
(...toolbar stuff...)
/>
(...some other stuff...)
</RelativeLayout>
<include layout="@layout/drawer" />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
如你所见,这是一个常规的DrawerLayout.请注意DrawerLayout,the RelativeLayout和the ImageViewall都将fitsSystemWindows属性设置为true.
我的问题是:如果我设置背景资源(如颜色或图片)来完成的DrawerLayout或RelativeLayout在上面的代码中,我可以看到"下面"的状态栏的颜色或图片,正是我所想要的,但ImageView's'src'drawable总是显示在它下面,好像它fitsSystemWindows完全忽略了属性一样.
我的主题中有以下属性:
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@color/primary_dark</item>
Run Code Online (Sandbox Code Playgroud)
随着primary_dark是一个半透明的黑色(这不应该怎样都无所谓,因为正如我所说,这似乎是专属我的一个问题ImageView.透明状态栏的作品完美无论是DrawerLayout或RelativeLayout.
我通过一个很好的教程,进行了一些更改,创建了一个自定义ListView,它允许我为ListView中的每一行显示多个图像.我想要做的是通过选择列表中的多个项目来突出显示,然后通过在我的选项菜单上选择一个选项,对所有这些列表项执行某种操作.但是,我似乎遇到的问题是我无法选择多个项目,即使我已经添加android:choiceMode="multipleChoice"到.xml文件中的ListView.我意识到这可以使用复选框或单选按钮完成,但我宁愿避免这种情况.我在下面附上了我的源代码.任何帮助,将不胜感激.最后,感谢http://custom-android-dn.blogspot.com/提供了一个很棒的教程.谢谢.
CustomlistviewActivity.java
package DucNguyen.example.customlistview;
public class CustomlistviewActivity extends Activity {
private ListView listViewFootballLegend;
private Context ctx;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_customlistview);
ctx=this;
List<FootballLegend> legendList= new ArrayList<FootballLegend>();
legendList.add(new FootballLegend("Pele","October 23, 1940 (age 72)","pele","brazil"));
legendList.add(new FootballLegend("Diego Maradona","October 30, 1960 (age 52)","maradona","argentina"));
legendList.add(new FootballLegend("Johan Cruyff","April 25, 1947 (age 65)","cruyff","netherlands"));
legendList.add(new FootballLegend("Franz Beckenbauer","September 11, 1945 (age 67)","beckenbauer","germany"));
legendList.add(new FootballLegend("Michel Platini","June 21, 1955 (age 57)","platini","france"));
legendList.add(new FootballLegend("Ronaldo De Lima","September 22, 1976 (age 36)","ronaldo","brazil"));
listViewFootballLegend = ( ListView ) …Run Code Online (Sandbox Code Playgroud) 我有ActionBarActivity一个GridView.
该GridView具有纵向两列,并在景观3列.
当我选择纵向(开始我的ActionMode)项目然后旋转设备时,所选项目突出显示将一个项目向左移动. 例如,如果我选择第二个项目并旋转,则第一个项目将突出显示.如果我选择第一个项目并旋转,则不会突出显示任何项目.
代码中的实际选择是正确的,只是突出显示是错误的.
我注意到如果我将numColumns保持为纵向和横向相同,它就不会这样做.
我相信这个问题是在我将我的活动改为之后开始发生的,ActionBarActivity所以它可能是一个错误.
任何人都知道为什么或如何解决它?
我正在使用new UIAlertController为我的应用程序实现各种选项菜单.我试图获得与UIAlertController我的应用程序其余部分的主题相匹配的背景颜色.我的应用程序的主题非常简单,包含工具栏和导航栏的蓝色/灰色背景颜色的白色文本,如下所示:

但是,我在尝试让我UIAlertController遵守这个主题时遇到了一些麻烦.我进行了以下两次调用来设置文本和背景颜色:
uiAlertController.view.backgroundColor = UIColor(red: CGFloat(.17255), green: CGFloat(.24314), blue: CGFloat(.31373), alpha: CGFloat(1.0))
uiAlertController.view.tintColor = UIColor.whiteColor()
Run Code Online (Sandbox Code Playgroud)
这改变了UIAlertController如下所示:

文本已从默认的蓝色系统颜色更改为白色,但背景颜色不正确.我也尝试修改指定opacity(uiAlertController.view.opaque = true),但这也没有帮助.如何设置背景颜色以使其与导航栏和工具栏匹配?谢谢
我一直在处理一个应用程序并需要一次性屏幕,以便只输入一次变量.我让用户输入卷号,如果它大于101400000,我只需要EditText在第一个屏幕上制作另一个.然后它移动到Activity具有Navgation Slider的main.
OneTime Activity显示屏幕.
package com.example.thereaper.thaparexpress;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
public class OneTime extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ot);
int counter=0;
if(counter==0) {
int roll = 0;
final Global global = (Global) getApplicationContext();
EditText rollNo = (EditText) findViewById(R.id.rollNo);
try {
roll = Integer.parseInt(rollNo.getText().toString());
} catch (NumberFormatException e) {
Toast.makeText(this, "Invalid roll number", Toast.LENGTH_SHORT);
}
if (roll >= 10140000) {
rollNo.setVisibility(View.VISIBLE); …Run Code Online (Sandbox Code Playgroud) 我有一个自定义Adapter,我用来显示自定义对象ListView.此外,我使用了一个SearchView允许我搜索ListView并过滤掉结果的.但是,当我尝试输入搜索时,我注意到了一些奇怪的行为.只要我搜索列表中的项目,项目就会显示在过滤器中 - 但是,项目始终显示在列表顶部.如果列表中有10个项目,并且搜索产生5个匹配项,则结果将显示列表中的前5个项目而不是5个实际匹配项目.例如,考虑一下这个列表上有6个摩托车头盔:
如果我搜索"ho",结果列表应如下所示:
但是,我得到的列表是前两项:
我无法弄清楚搜索无法正常工作的原因.任何帮助,将不胜感激.我的代码如下所示......
HelmetActivity.java
public class HelmetActivity extends ActionBarActivity implements
SearchView.OnQueryTextListener{
private Menu menu;
private ListView listView;
private HelmetAdapter helmetAdapter;
private List<Helmet> arrayList;
private SearchManager searchManager;
private SearchView searchView;
private MenuItem searchMenuItem;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.helmet_activity);
ActionBar actionBar = getSupportActionBar();
actionBar.setElevation(0);
listView = (ListView) findViewById(R.id.helmet_listview);
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
arrayList = new ArrayList<Helmet>();
listView.setLongClickable(true); …Run Code Online (Sandbox Code Playgroud)