如何在背景Textview中有颜色(即白色)的情况下制作约20%透明(不完全透明)的背景?
我试图了解Android中的颜色是如何工作的.我把这个颜色设置为我的背景LinearLayout,然后我得到一个透明的背景灰色:
<gradient android:startColor="#b4555555" android:endColor="#b4555555"
android:angle="270.0" />
Run Code Online (Sandbox Code Playgroud)
如果我删除最后两个字符(55),我会得到一个纯色,失去透明度.我试图找到一个页面,我可以看到有关此的一些解释,但我找不到它.
我使用这个CSS作为背景不透明度<div>:
background: rgba(255, 255, 255, 0.3);
Run Code Online (Sandbox Code Playgroud)
它在Firefox中运行良好,但在IE 8中运行不正常.如何使其工作?
我正在开发Android项目,我正在实现导航抽屉.我正在阅读新的材料设计规范和材料设计清单.
规范说滑出窗格应该浮动在其他所有内容之上,包括状态栏,并且在状态栏上是半透明的.
我的导航面板位于状态栏上,但没有任何透明度.我按照Google开发者博客网站上的建议点击了这篇SO帖子中的代码,上面的链接如何使用DrawerLayout显示在ActionBar /工具栏上和状态栏下?.
下面是我的XML布局
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/my_awesome_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="@color/appPrimaryColour" />
</LinearLayout>
<LinearLayout android:id="@+id/linearLayout"
android:layout_width="304dp"
android:layout_height="match_parent"
android:layout_gravity="left|start"
android:fitsSystemWindows="true"
android:background="#ffffff">
<ListView android:id="@+id/left_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"></ListView>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
以下是我的应用主题
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/appPrimaryColour</item>
<item name="colorPrimaryDark">@color/appPrimaryColourDark</item>
<item name="colorAccent">@color/appPrimaryColour</item>
<item name="windowActionBar">false</item>
<item name="windowActionModeOverlay">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
以下是我的应用程序v21主题
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/appPrimaryColour</item>
<item name="colorPrimaryDark">@color/appPrimaryColourDark</item>
<item name="colorAccent">@color/appPrimaryColour</item>
<item name="windowActionBar">false</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
下面是我的onCreate方法 …
android navigation-drawer material-design android-5.0-lollipop
我试图将十六进制值转换为int,以便我可以创建一个新的颜色drawable.我不确定这是否可行,但根据文档,它应该.它显然要求
public ColorDrawable(int color)
在API级别1中添加创建具有指定颜色的新ColorDrawable.
参数 color 要绘制的颜色.
所以,我的代码不起作用,因为我得到一个无效的int:"FF6666"错误.有任何想法吗?
int decode = Integer.decode("FF6666");
ColorDrawable colorDrawable = new ColorDrawable(decode);
Run Code Online (Sandbox Code Playgroud) 我有以下渐变:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#ECECEC"
android:centerColor="#F6F6F4"
android:endColor="#F8F8F6"
android:angle="90"
android:dither="true"
/>
</shape>
Run Code Online (Sandbox Code Playgroud)
我希望这是透明的,因为在我的ListView中我将其设置为我的ListSelector:
<ListView android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ARListView"
android:background="@drawable/transparent_background"
android:cacheColorHint="#00000000" android:drawSelectorOnTop="true"
android:listSelector="@drawable/stocks_selected_gradient">
</ListView>
Run Code Online (Sandbox Code Playgroud) 我有一个线性布局,其中每行以编程方式膨胀,我希望这些行在单击时表现得像ListView.也就是说,我希望行以与默认ListView完全相同的方式/颜色突出显示.我该怎么做呢?
我需要为xml drawable中的颜色设置不透明度值.但是当我尝试添加两个不透明度值(#20C0C0C0)时,不起作用.颜色看起来完全透明.
这是我的代码......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners
android:radius="2dp" />
<solid
android:color="#CDCDCD" />
<stroke
android:width="2dp"
android:color="@android:color/darker_gray" />
<size
android:height="60dp"
android:width="80dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
有人有想法吗?谢谢你的帮助.
嗨我有一个布局,我用来填充我的页面,我必须在我drawable folder的布局中设置一个背景图像.
我想alpha value将图像设置为相当低的几乎使图像像水印一样.
我的xml看起来像
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/background"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/main_background" >
Run Code Online (Sandbox Code Playgroud)
如您所见,我已为布局分配了一个ID
我想在我的创造中我可以做这样的事情吗?
View backgroundimage = (View) findViewById(R.id.background);
backgroundimage.setAlpha(80);
Run Code Online (Sandbox Code Playgroud)
这不起作用,但我怀疑它是因为我试图将背景作为View我应该把它投射为什么?
EditText我的代码中有一些,我想让它的底部边框更薄一些.在互联网上找不到任何关于它的信息,也许这里的任何人都可以帮助我.
是)我有的:

我想要的是:
