标签: android-theme

Android TextInputLayout 和 TextInputEditText 光标颜色问题

在此处输入图片说明问题

我有这个问题,在xxx是紫色的光标后,我想知道那个放置光标的名称,我想更改颜色以匹配我的主题。我阅读了许多论坛和文档,唯一找到的是 cursorDrawable,但事实并非如此。请帮我搜索正确的名称或解决方案。谢谢 PD:那东西的紫罗兰色不是我的风格或颜色。

android android-theme android-styles android-textinputlayout material-components-android

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

当设备可以在应用程序级别强制使用时,如何避免在我的应用程序中强制使用深色主题?

某些设备(例如Poco F2 Pro)可以在与深色主题不兼容的应用程序中强制使用深色主题。

例如,我的应用程序具有此主题并且与深色主题不兼容:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
Run Code Online (Sandbox Code Playgroud)

这是我的清单应用程序部分,未启用深色主题:

<application
    android:name=".helpers.CustomApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:largeHeap="true"
    android:theme="@style/AppTheme">
Run Code Online (Sandbox Code Playgroud)

问题是像Poco F2 Pro这样的设备在应用程序中强制使用深色主题时,会使我的应用程序以不正确和异常的颜色显示,从而破坏 UI。

可以避免吗?

如何强制黑暗主题:https : //www.androidauthority.com/android-q-force-dark-mode-984090

android android-theme android-dark-theme

1
推荐指数
2
解决办法
2111
查看次数

TextInputLayout Material 组件问题:此组件上的样式要求您的应用程序主题为 Theme.MaterialComponents(或后代)

我在使用 TextInputLayout 实现材质设计时遇到问题,我知道解决方案是让您的活动主题继承材质组件主题之一,但这会给我的大多数应用程序主题带来此类更改,并且需要更多时间来重构它。我想要的是应用程序上这个特定 TextInputLayout 的材质设计。

这就是我尝试过的

<com.google.android.material.textfield.TextInputLayout
                android:id="@+id/firstName"
                style="@style/CustomInputStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginEnd="5dp"
                android:layout_weight="1"
                app:errorEnabled="true">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/fname"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/first_name"
                    android:inputType="text|textCapWords"
                    android:nextFocusDown="@id/lname"
                    android:textSize="12sp" />

</com.google.android.material.textfield.TextInputLayout>




<style name="CustomInputStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
            <item name="boxStrokeWidth">2dp</item>
            <item name="hintTextColor">@color/colorAccent</item>
            <item name="boxStrokeColor">@android:color/white</item>
            <item name="android:colorAccent">@color/colorAccent</item>
            <item name="android:textColorHint">@color/colorAccent</item>
        </style>
Run Code Online (Sandbox Code Playgroud)

错误 : Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant).

我们不能这样做而不是覆盖整个应用程序/活动主题吗?我想要的只是在特定的片段中使用它。

android android-theme material-design material-components-android

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

带有(架构导航组件)和 BottomNavigationView 的初始屏幕

我试图在包含BottomNavigationView三个片段的应用程序中实现启动屏幕,并且我使用了最著名的方法,例如在不创建新活动或片段的情况下执行此操作的答案,但在直接启动启动屏幕后出现问题,它得到“RuntimeException”和空指针异常”

\n
E/AndroidRuntime: FATAL EXCEPTION: main\n    Process: com.mml.foody, PID: 6868\n    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mml.foody/com.mml.foody.ui.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method \'void androidx.appcompat.app.ActionBar.setTitle(java.lang.CharSequence)\' on a null object reference\n        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)\n        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)\n        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)\n        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)\n        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)\n        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)\n        at android.os.Handler.dispatchMessage(Handler.java:106)\n        at android.os.Looper.loop(Looper.java:223)\n        at android.app.ActivityThread.main(ActivityThread.java:7656)\n        at java.lang.reflect.Method.invoke(Native Method)\n        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)\n        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)\n     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method \'void androidx.appcompat.app.ActionBar.setTitle(java.lang.CharSequence)\' on a null object reference\n        at androidx.navigation.ui.ActionBarOnDestinationChangedListener.setTitle(ActionBarOnDestinationChangedListener.java:48)\n        at androidx.navigation.ui.AbstractAppBarOnDestinationChangedListener.onDestinationChanged(AbstractAppBarOnDestinationChangedListener.java:103)\n        at androidx.navigation.NavController.addOnDestinationChangedListener(NavController.java:233)\n …
Run Code Online (Sandbox Code Playgroud)

android splash-screen android-theme kotlin android-databinding

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

使用白色背景颜色配置Android活动全屏

我对Android应用程序开发很陌生.我希望我的第一个活动以全屏显示白色背景.我怎样才能做到这一点?

android android-theme

0
推荐指数
1
解决办法
3764
查看次数

setVisibility() 不刷新活动布局

我在微调项目选择时将按钮的可见性设置为可见或消失:-

selectUserTypeSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view,
                    int position, long id) {
                FilterUserType newUserType = FilterUserType.get(position);
                if(filter.userType != newUserType){
                    filter.userType = newUserType;
                    ScrollView mainScrollView =  (ScrollView) findViewById(R.id.mainLayout);
                    switch (newUserType) {
                    case AnyUser:
                    case CurrentUser:{
                        selectUserBtn.setVisibility(View.GONE);
                        break;
                    }
                    case SpecificUser:{
                        selectUserBtn.setVisibility(View.VISIBLE);
                        break;
                    }
                    default:
                        break;
                    }
                }
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {}

        });
Run Code Online (Sandbox Code Playgroud)

这里的问题是我的视图在此操作后没有刷新,但是当我在页面上选择一个 EditText 并且键盘已启动时......当时它会刷新并显示所需的行为。

我曾尝试将 switch-case 编辑为:-

switch (newUserType) {
    case AnyUser:
    case CurrentUser:{
        selectUserBtn.setVisibility(View.GONE);
        mainScrollView.invalidate();
        break;
    }
    case SpecificUser:{
        selectUserBtn.setVisibility(View.VISIBLE);
        mainScrollView.invalidate();
        break; …
Run Code Online (Sandbox Code Playgroud)

android visibility android-theme android-holo-everywhere

0
推荐指数
1
解决办法
3726
查看次数

4.0+应用程序中的旧主题

我在我的活动中创建了一个微调器,当我在我的Jelly Bean设备上运行我的应用程序时,微调器的主题就像2.x,我怎样才能获得ICS?

这是我的微调代码:

    <Spinner
      android:id="@+id/spinnermap"
      style="@android:style/Theme.Holo"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_centerVertical="true" />
Run Code Online (Sandbox Code Playgroud)

正如你所看到我试图设置全局样式"Holo"但没有结果..

我有同样的问题,NumberPicker但不记得我是如何修复它的.

android spinner android-theme android-4.0-ice-cream-sandwich

0
推荐指数
1
解决办法
1913
查看次数

在Theme.Holo.Light上使用Theme.Light Datepicker

我有一个使用Theme.Holo.Light的活动,包含EditText,RadioButtons和DatePicker.我想使用Theme.Holo.Light进行整个活动,除了DatePicker,我想成为Theme.Light风格.我怎样才能做到这一点?

android android-layout android-theme

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

更改dialogfragment背景颜色(使用Android Holo Colors Generator Xml模板)

我的所有主题都在我的dialogfragment背景下工作.我试图让我的dialogFragment背景变黑,但我做错了什么.

这里到目前为止我在主题xml中得到了什么(请注意,我将它的顶部和底部封顶):

<style name="easydealtheme" parent="@style/_easydealtheme"/>

  <style name="_easydealtheme" parent="android:Theme.Holo.Light.DarkActionBar">

<item name="android:editTextBackground">@drawable/easydealtheme_edit_text_holo_light</item>

<item name="android:dropDownListViewStyle">@style/Listviewdropdowneasydealtheme</item>
<item name="android:textViewStyle">@style/Textvieweasydealtheme</item>
<item name="android:editTextStyle">@style/Edittexteasydealtheme</item>

<item name="android:alertDialogTheme">@style/Dialogeasydealtheme</item>
...
Run Code Online (Sandbox Code Playgroud)

这是我在我的对话框的Styles xml中得到的:

<style name="Dialogeasydealtheme" parent="android:Theme.Holo.Dialog">
<item name="android:textColor">#FFFFFF</item>
<item name="android:windowBackground">@color/test</item>
</style>
Run Code Online (Sandbox Code Playgroud)

以下是显示dialogFragment的代码:

 public static void ShowPhotoDialog(String title,File photoFile, FragmentManager fragM)
    {

        FragmentPhotoDialog photoD = new FragmentPhotoDialog();
        FragmentTransaction fTX  = fragM.BeginTransaction();
        photoD.SetStyle(DialogFragmentStyle.NoFrame, EasyDeal_Android.Resource.Style.easydealtheme);
        photoD.SetTile(title);
        photoD.SetPhotoFile(photoFile);
        photoD.Show(fTX, "Dialog");

    }
Run Code Online (Sandbox Code Playgroud)

这里的结果不起作用(白色应为黑色): DF

android android-layout android-theme android-fragments

0
推荐指数
1
解决办法
8678
查看次数

无法使用appcompact v7和Android Studio 1.1 Preview更改操作栏的颜色

我尝试了很多样式来改变动作栏的颜色,但没有奏效.

这是我的风格:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="actionBarStyle">@style/AppTheme.ActionBarStyle</item>
</style>
 <style name="AppTheme.ActionBarStyle" parent="Widget.AppCompat.ActionBar.Solid">
    <item name="android:background">#f01234</item>
</style>
Run Code Online (Sandbox Code Playgroud)

我的模拟器版本:Android 4.2

android android-theme android-actionbar

0
推荐指数
1
解决办法
2315
查看次数

使用Theme.AppCompat时,操作栏颜色不会更改

我所要做的就是让动作栏和状态栏改变颜色以进行材料设计.以下是我创建的主题:

 <!-- Base application theme. -->
<style name="AppTheme2" parent="Theme.AppCompat">
    <!-- colorPrimary is used for the default action bar background -->
    <item name="android:colorPrimary">#FF5722</item>
    <!--<item name="android:statusBarColor">#E64A19</item>-->

    <!-- colorPrimaryDark is used for the status bar -->
    <item name="android:colorPrimaryDark">#E64A19</item>


    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="android:colorAccent">#FF9800</item>

    <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight & colorSwitchThumbNormal. -->

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

但是,运行状态栏时,颜色会变好,但操作栏仍为黑色.我知道可能有一个简单的答案,但我错过了什么?

这个问题与建议的问题不重复.请删除标志.

android android-appcompat android-theme

0
推荐指数
1
解决办法
1205
查看次数

如何使用新版本的 getresources().getColor?

我正在尝试使用颜色元素,getresources.getColor(resource id)但 android 告诉我它已被弃用 use getresources.getColor(resource id, theme)

我如何告诉它使用什么主题?我试过了,R.style.AppTheme但我收到一个错误,因为这是一个 int 值

public class TodoListItemView extends AppCompatTextView {
    public TodoListItemView(Context context, AttributeSet attributeSet, int ds) {
        super(context, attributeSet, ds);
        init();
    }

    public TodoListItemView(Context context) {
        super(context);
        init();
    }

    public TodoListItemView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        init();
    }

    private Paint marginPaint;
    private Paint linePaint;
    private int paperColor;
    private float margin;

    private void init() {
        Resources myResources = getResources();
        marginPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        marginPaint.setColor(getResources().getColor(R.color.notepad_margin));
        linePaint = new …
Run Code Online (Sandbox Code Playgroud)

android android-theme android-color

-1
推荐指数
1
解决办法
4963
查看次数