相关疑难解决方法(0)

Android 6.0 Marshmallow停止显示Vertical SeekBar thumb

我一直在SeekBar周围使用这个基本的包装,但发现它隐藏了拇指,或做了一些时髦的东西,比如在白色背景上使它变成白色,在Marshmallow下面.

我使用AS"BlankActivity"向导来创建一个项目来说明这一点,除了默认设置之外什么都没有改变.左边是Lollipop,同样的代码在Marshmallow右边运行:

在此输入图像描述

有一个自定义水平SeekBar来测试是否存在定制它们的一般问题,但没有.左边的第一个垂直方向没有样式,这在Marshmallow之前很好,但是没有其他方式,中央显式使用Widget.Material.Light.SeekBar样式来测试默认情况是否未被拾取,并且最后一个给出了一个很大的线索,因为它使用旧的Widget.Holo.SeekBar样式然后出现,虽然看起来它几年前出现.

这是这个的布局:

<?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" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".MainActivity"
    >

    <com.otamate.seekbarmarshbug.CustomSeekBar
        android:id="@+id/seekBarCustom"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />

    <com.otamate.seekbarmarshbug.VerticalSeekBar
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_below="@+id/seekBarCustom"
        />

    <com.otamate.seekbarmarshbug.VerticalSeekBar
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:gravity="center_horizontal"
        android:layout_below="@+id/seekBarCustom"
        android:layout_centerHorizontal="true"
        style="@android:style/Widget.Material.Light.SeekBar"
        />

    <com.otamate.seekbarmarshbug.VerticalSeekBar
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/seekBarCustom"
        style="@android:style/Widget.Holo.SeekBar"
        />

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

CustomSeekBar:

package com.otamate.seekbarmarshbug;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.SeekBar;

public class CustomSeekBar extends SeekBar {

    public CustomSeekBar(Context context) {
        super(context);
    }

    public CustomSeekBar(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public …
Run Code Online (Sandbox Code Playgroud)

android seekbar

7
推荐指数
3
解决办法
3269
查看次数

自定义搜索栏采用材料设计

我在自定义对话框首选项的布局中有一个搜索栏.我更改了styles.xml以使用新的材料设计.它的工作原理是它更改了我的设置的文本和复选框,但我无法将颜色应用到我的搜索栏.它只有在我将一个搜索栏放在一个活动中才有效,这意味着我必须在我的自定义布局中做一些事情,但我不知道是什么.我使用搜索栏发布styles.xml和布局:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="AppBaseTheme" parent="android:Theme.Material">

        <!-- Main theme colors -->
        <!-- your app's branding color (for the app bar) -->
        <item name="android:colorPrimary">#FFFF4444</item>
        <!-- darker variant of colorPrimary (for status bar, contextual app bars) -->
        <item name="android:colorPrimaryDark">#FFCC0000</item>
        <!-- theme UI controls like checkboxes and text fields -->
        <item name="android:colorAccent">#FFFF00</item>
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
    </style>

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

对话框首选项的自定义布局

<?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" >

    <SeekBar
        android:id="@+id/seek_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="6dip"
        android:theme="@android:style/Theme.Material"
        android:layout_marginTop="6dip" />

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

android material-design

5
推荐指数
2
解决办法
2万
查看次数

标签 统计

android ×2

material-design ×1

seekbar ×1