如何在Android中为矩形形状添加投影

时间:2015-06-12 08:15:51

标签: android android-layout shadow dropshadow roundedcorners-dropshadow

我正在开发一个Android应用程序,我需要使用一个矩形形状,它应该有一个drop_shadow。我设计了一个矩形的形状,但不知怎的,我无法在它(右侧和左侧)添加一个投影。 P.S。:这个矩形形状被添加为背景属性。

如果此类问题已经得到解答,请在此处提供链接。

谢谢你提前!!!!

enter image description here

代码:

    <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#ffffff" />
    <stroke
        android:width="1dp"
        android:color="#000000" />
    <corners
        android:radius="10dp"   >
    </corners>

</shape>

1 个答案:

答案 0 :(得分:1)

试试这个:

 - (void)imagePickerController:(UIImagePickerController *)picker
        didFinishPickingMediaWithInfo:(NSDictionary *)info
 {

    if ([picker sourceType] == UIImagePickerControllerSourceTypePhotoCamera) {
    // We'll store the info to use in another function later
    self.imageInfo = info;

    // Get the asset url
    NSURL *url = [info objectForKey:@"UIImagePickerControllerReferenceURL"];

    // We need to use blocks. This block will handle the ALAsset that's returned: 
    ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
    {
        // Get the location property from the asset  

        CLLocation *location = [myasset valueForProperty:ALAssetPropertyLocation];
        // I found that the easiest way is to send the location to another method

        self.lat =location.coordinate.latitude; //[[gpsdata valueForKey:@"Latitude"]floatValue];
        self.lng =location.coordinate.longitude;
        NSLog(@"\nLatitude: %f\nLongitude: %f",self.lat,self.lng);

        strLocation=[NSString stringWithFormat:@"La:%f Lo%f",self.lat,self.lng];

        NSLog(@"Can not get asset - %@",strLocation);

    };
    // This block will handle errors:
    ALAssetsLibraryAccessFailureBlock failureblock  = ^(NSError *myerror)
    {
        NSLog(@"Can not get asset - %@",[myerror localizedDescription]);

    };

    ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
    [assetslibrary assetForURL:url 
                   resultBlock:resultblock
                  failureBlock:failureblock];

}
 }