小编H. *_*aul的帖子

带有黑暗工具栏的Android Theme.AppCompat.Light(用于浅色文字)

我有一个应用程序Theme.AppCompat.Light,我需要使用它,所以Dialogs有轻主题.但这会使我的工具栏中的文字变黑,我宁愿它变成白色.我试过设置工具栏的具体app:theme到AppCompat.Dark.Actionbar,但没有运气...我搜索了一段时间,但没有找到一个具体的问题和答案.

这是我的默认AppTheme:

<style name="AppTheme.Parent" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/blue</item>
    <item name="colorPrimaryDark">@color/dark_blue</item>
    <item name="colorAccent">@color/pink</item>

    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)

这是我的toolbar.xml:

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:minHeight="@dimen/abc_action_bar_default_height_material"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
Run Code Online (Sandbox Code Playgroud)

android android-appcompat material

12
推荐指数
1
解决办法
1万
查看次数

PreferenceFragment重叠工具栏

作为标题,我的PreferenceFragment与我的工具栏重叠.我已经尝试过不同的解决方案,但问题仍然存在.希望在任何帮助.这是我的代码.

活动:

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

public class MyActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings);

        Toolbar toolbar = (Toolbar) findViewById(R.id.app_bar);
        setSupportActionBar(toolbar);

        // Display the fragment as the main content
        getFragmentManager().beginTransaction().replace(android.R.id.content, new SettingsFragment()).commit();
    }
}
Run Code Online (Sandbox Code Playgroud)

活动XML(activity_settings.xml):

<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context="com.mypackage.MyActivity">

    <include
        layout="@layout/app_bar" />

    <FrameLayout
        android:id="@+id/pref_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/app_bar"/>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

片段(SettingsFragment.java):

import android.preference.PreferenceFragment;
import android.os.Bundle;

public class SettingsFragment extends PreferenceFragment {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Load …
Run Code Online (Sandbox Code Playgroud)

xml android android-preferences

6
推荐指数
1
解决办法
4042
查看次数