我试图<shape>在android drawable xml 的元素中的矩形上实现有效的2笔画.深绿色外线和浅绿色内线,在其中心有渐变填充.我的代码目前看起来像这样:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="3px" android:color="#477135" />
</shape>
</item>
<item >
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#81c557" android:endColor="#539942"
android:angle="270" />
<stroke android:width="1px" android:color="#a8d78a" />
</shape>
</item>
Run Code Online (Sandbox Code Playgroud)
我尝试将android:top ="3px"android:bottom ="3px"应用到第二个项目元素,但是当我添加右侧和左侧属性时,整个事物都不会渲染.注意,这都是在ListView中完成的
如果我通过代码绘制圆形矩形,我可以使用setShadowLayer来获取形状的阴影.在XML中定义形状时是否存在等价物?
以下示例将圆形rect背景绘制为形状.我需要添加什么才能将阴影添加到形状中?甚至可以使用XML吗?
shape_test.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#8067BF6A"/>
<stroke android:width="3dp" android:color="#80000000" />
<padding android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp" />
<corners android:bottomRightRadius="7dp"
android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:background="#ffdddddd"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button android:background="@drawable/shape_test"
android:padding="5dp"
android:textStyle="bold"
android:textSize="28sp"
android:text="Hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我想开发一个替换键盘,但我担心Android会假设一般键盘"区域"将是位于屏幕底部的单个矩形形状.
如果我希望我的键盘由多个不仅仅位于屏幕底部的形状组成,该怎么办?我是从一开始就注定的,还是可以做我想做的事情?
在相关的说明中,如果我只想在手机处于某个方向时显示键盘,但是当手机保持在不同的方向时,会使用普通的软键怎么办?再次,运气不好或可能吗?
干杯!
我试图动画圆角矩形的宽度,问题是当从更大的宽度变为更宽的宽度时,动画会进行"像差轻松跳跃".
这是代码:
shapeLayer = [CAShapeLayer layer];
shapeRect = CGRectMake(0.0f, 0.0f, 150.0f, 200.0f);
[shapeLayer setBounds:shapeRect];
[shapeLayer setPosition:CGPointMake(iniPosX, 80.0f)];
[shapeLayer setFillColor:[[UIColor blackColor] CGColor]];
[shapeLayer setStrokeColor:[[UIColor clearColor] CGColor]];
[shapeLayer setLineWidth:1.0f];
[shapeLayer setLineJoin:kCALineJoinRound];
[shapeLayer setOpacity:0.2];
path = [UIBezierPath bezierPathWithRoundedRect:shapeRect cornerRadius:15.0];
[shapeLayer setPath:path.CGPath];
[self.layer addSublayer:shapeLayer];
Run Code Online (Sandbox Code Playgroud)
当我开始动画时:
- (void)adjustSelectorToPosAndSize:(float)posX andWidth:(float)width
{
shapeRect = CGRectMake(0.0f, 0.0f, width, 200.0f);
[shapeLayer setBounds:shapeRect];
[shapeLayer setPosition:CGPointMake(posX, 80.0f)];
path = [UIBezierPath bezierPathWithRoundedRect:shapeRect cornerRadius:15.0];
[shapeLayer setPath:path.CGPath];
}
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我想LinearLayout在此图片的边框周围加上标题。
布局http://img829.imageshack.us/img829/3461/borderwithtitel.png
我已经有边界了。
如何添加标题?
我通过.xml在drawable文件夹中创建文件来创建边框。在那里我制作了一个形状,然后将线性布局的背景设置为此形状。
我正在使用API级别8。
我现在已经使用jvectormap几周了,但是有很多缺少的国家.有谁知道我在哪里可以获得jvectormap格式的国家/地区信息?
我在谷歌搜索了几个小时但找不到任何东西.
有一个jqvmap与几个国家,但它是一个不同的预测,也有一些国家失踪.
目前我正在使用:
jvectormap-world-en.js
Run Code Online (Sandbox Code Playgroud)
我无法处理python转换器.
有没有人有这个来源?
我有n个圆圈,必须完美地围绕椭圆,如下图所示:

在这张图片中,我需要找出椭圆周围每个圆的位置,并且还能够计算出完全适合周围圆圈的椭圆.
我知道的信息是每个圆的半径(全部相同)和圆的数量.
希望这次帖子很清楚.谢谢你的帮助.如果您需要更多解释,请告诉我.
如何在CSS3中创建以下形状,而不使用像":before"这样的伪类?

我之前做过很简单,但事情是我不想在灰色区域有一个坚实的元素(参见JSFiddle - http://jsfiddle.net/aUdLr/2/)
div{
width: 100px;
height: 100px;
background-color: red;
border-radius: 100%;
position: relative;
}
div:before{
content: "";
width: 100%;
height: 110%;
background: gray;
position: absolute;
left: 5px;
top: -5%;
border-radius: 100%;
}
Run Code Online (Sandbox Code Playgroud) 我正在实现一种方法,在Android中使用此方法在Google Map(v2)上显示搜索半径:
// Method for drawing a circle around the user
private void drawMapSearchRadius(int radius) {
if(mMap != null) {
final LatLng userLatLng = getUserLatLng();
if(mSearchCircle == null){
CircleOptions circleOptions = new CircleOptions();
circleOptions.fillColor(Color.parseColor("#447755ff"));
circleOptions.strokeColor(Color.TRANSPARENT);
circleOptions.center(userLatLng);
circleOptions.radius(radius);
mSearchCircle = mMap.addCircle(circleOptions);
} else {
mSearchCircle.setCenter(userLatLng);
mSearchCircle.setRadius(radius);
}
}
}
Run Code Online (Sandbox Code Playgroud)
半径是用SeekBar确定的,就像这样(我删除了一些不相关的代码):
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
final int radius = progress + DEFAULT_MIN_RADIUS;
drawMapSearchRadius(radius);
...
Run Code Online (Sandbox Code Playgroud)
当我滑动SeekBar时,圆的半径会按预期变化,但它会明显闪烁很多.它的外观和感觉非常糟糕.
有没有人遇到过这个错误,可以告诉我我做错了什么或者我能做些什么来限制,或者在最好的情况下,消除圆圈闪烁?
提前致谢
由于谷歌不是很快就能修复这样的错误,所以我没有希望解决这个问题.所以我想我的问题正在改变:有什么办法可以解决这个问题吗?
我在android中创建自定义按钮但想避免重复.
我正在尝试创建2个可切换的按钮,这些按钮共享相同的设计但是不同的图像图标而不是文本.
目前我有这个:
我正在使用此xml作为可绘制资源:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<item>
<shape>
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp" />
<corners android:radius="20dp"/>
</shape>
</item>
<item>
<shape>
<padding
android:bottom="5dp"
android:left="-5dp"
android:right="5dp"
android:top="-5dp" />
<solid android:color="#edebeb"></solid>
<corners android:radius="20dp"/>
</shape>
</item>
<item>
<shape>
<size android:height="150dp" android:width="150dp"></size>
<padding
android:bottom="5dp"
android:left="-5dp"
android:right="5dp"
android:top="-5dp" />
<solid android:color="#fff"></solid>
<corners android:radius="20dp"/>
</shape>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
如何在不复制xml文件的情况下在每个按钮的中心显示不同的图像?
有没有什么办法可以将值传递给我活动的.java文件中的每个按钮,以便我可以使用它为每个按钮显示不同的图像?
shape ×10
android ×6
layout ×2
xml ×2
algorithm ×1
animation ×1
border ×1
cashapelayer ×1
css-shapes ×1
css3 ×1
drawable ×1
geometry ×1
google-maps ×1
html ×1
ios ×1
jvectormap ×1
keyboard ×1
pseudo-class ×1
replace ×1
stroke ×1