相关疑难解决方法(0)

六角透明的颜色

我正在为我的应用程序小部件实现一个小部件透明度选项,尽管我在修复十六进制颜色值时遇到了一些麻烦.作为十六进制颜色透明度的全新,我搜索了一下,虽然我找不到我的问题的具体答案.

我想用十六进制颜色设置透明度,所以让我说我的十六进制颜色ID"#33b5e5",我希望它是50%透明.然后我会使用"#8033b5e5",因为80%是50%.

我在这里找到了一个有用的图表:http://www.dtp-aus.com/hexadeci.htm.有了这些数据,我设法得到了这个:

0% = #00
10% = #16
20% = #32
30% = #48
40% = #64
50% = #80
60% = #96
70% = #112
80% = #128
90% = #144
Run Code Online (Sandbox Code Playgroud)

现在,当我以十六进制高于100时问题开始出现.十六进制颜色代码只能长8个符号吗?例如#11233b5e5(80%)崩溃.

我能做些什么才能让我使用更高的数字呢?

transparency android hex colors

1219
推荐指数
7
解决办法
93万
查看次数

如何使用DrawerLayout在ActionBar /工具栏上和状态栏下显示?

我在新的材料设计Side Nav规范中看到,您可以在操作栏上和状态栏后面显示抽屉.我该如何实现呢?

android android-appcompat navigation-drawer

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

了解Android上的颜色(六个字符)

我试图了解Android中的颜色是如何工作的.我把这个颜色设置为我的背景LinearLayout,然后我得到一个透明的背景灰色:

<gradient android:startColor="#b4555555" android:endColor="#b4555555"
 android:angle="270.0" />
Run Code Online (Sandbox Code Playgroud)

如果我删除最后两个字符(55),我会得到一个纯色,失去透明度.我试图找到一个页面,我可以看到有关此的一些解释,但我找不到它.

transparency android hex colors

202
推荐指数
6
解决办法
15万
查看次数

将ListView或RecyclerView添加到新的NavigationView

我正在使用Google 支持库版本22.2.0中的新NavigationView.它可以很好地生成使用菜单res填充的导航抽屉.

我想知道是否可以将ListView或RecyclerView添加到导航抽屉,以便可以使用我的自定义适配器代码填充它,这允许比菜单资源更大的灵活性.

这是我目前的XML:

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

<android.support.v4.widget.DrawerLayout
    android:id="@+id/drawer_layout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".MainActivity">

    <FrameLayout
        android:id="@+id/content_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

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

    </FrameLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:headerLayout="@layout/navigation_drawer_header"
        app:menu="@menu/menu_navigation_drawer" />


</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

在我的XML中,我会添加ListView或RecyclerView吗?

编辑

根据Basant的建议,我将ListView嵌套到NavigationView中.你失去了从菜单res(据我所知)膨胀的能力,但它成功地按照我的意愿去做.标头XML未更改,它只包含在XML中.

新代码:

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

<android.support.v4.widget.DrawerLayout
    android:id="@+id/drawer_layout"
    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:fitsSystemWindows="true"
    tools:context=".MainActivity">

    <FrameLayout
        android:id="@+id/content_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

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

    </FrameLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <include
                android:id="@+id/navigation_drawer_header_include"
                layout="@layout/navigation_drawer_header" />

            <ListView
                android:id="@+id/navigation_drawer_list"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@id/navigation_drawer_header_include"/>

        </RelativeLayout>

    </android.support.design.widget.NavigationView> …
Run Code Online (Sandbox Code Playgroud)

android listview android-recyclerview navigationview

20
推荐指数
3
解决办法
3万
查看次数

将导航抽屉放在状态栏下

我正在尝试让我的导航抽屉进入状态栏.我已经阅读了很多关于ScrimInsetsFrameLayout视图的内容,我尝试实现它,但由于某种原因它不会被删除.

这是我使用/编写的代码.

XML DrawerLayout:

<android.support.v4.widget.DrawerLayout
    android:id="@+id/drawer_layout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <FrameLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

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

    </FrameLayout>

    <com.andrewq.planets.util.ScrimInsetsFrameLayout
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/linearLayout"
        android:layout_width="304dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:insetForeground="#4000">

        <ListView
            android:id="@+id/left_drawer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:choiceMode="singleChoice" />
    </com.andrewq.planets.util.ScrimInsetsFrameLayout>


</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

ScrimInsetsFrameLayout.java:

package com.andrewq.planets.util;

/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License …
Run Code Online (Sandbox Code Playgroud)

android

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

导航抽屉在牛轧糖的状态栏上?

我尝试在我的应用程序中构建导航抽屉,导航抽屉在以前版本的牛轧糖中工作正常但在牛轧糖导航抽屉中没有来自状态栏.我尝试了很多解决方案,但不能在牛轧糖工作,请帮助!!

这是我的activity_main.xml文件:

 <android.support.v4.widget.DrawerLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/drawerLayoutId"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
        android:fitsSystemWindows="true"    
        android:id="@+id/activity_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        tools:context="com.example.pushpam.helloworld.MainActivity">

        <include
            layout="@layout/custom_tool_bar"
            android:id="@+id/customtollbarimportid"/>

        <TextView
            android:textSize="80dp"
            android:textColor="#E9CC0014"
            android:text="I"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/customtollbarimportid"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginLeft="65dp"
            android:layout_marginStart="65dp"
            android:layout_marginTop="79dp"
            android:id="@+id/textView" />

        <TextView

            android:textSize="80dp"
            android:textColor="#E9CC0014"
            android:text="Love"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textView2"
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true" />

        </RelativeLayout>

    <fragment
        android:fitsSystemWindows="true"
        android:id="@+id/nav_drawer_fragment_id"
        android:layout_width="280dp"
        android:layout_height="match_parent"
        app:layout="@layout/fragment_navigationfragment"
        android:layout_gravity="start"
        android:name="com.example.pushpam.helloworld.navigationfragment"
        tools:layout="@layout/fragment_navigationfragment" />

    </android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

我的styles.xml:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

</style>

<style name="CustomToolBarTheme">

    <item name="android:textColorPrimary">@color/toolBarTextColor</item> …
Run Code Online (Sandbox Code Playgroud)

xml android appbar statusbar navigation-drawer

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

Android-将色调背景颜色更改为导航抽屉?

我正在使用导航抽屉,我需要将色调背景的颜色从黑色更改为绿色。有任何想法吗?

在此处输入图片说明

android navigation-drawer

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