相关疑难解决方法(0)

Android LinearLayout:在LinearLayout周围添加阴影边框

我想创建此LinearLayout的相同边框作为示例:

在此输入图像描述

在这个例子中,我们可以看到linearLayout周围的边界不一样.如何使用XML可绘制文件创建它?

现在,我只能在LinearLayout周围创建一个简单的边框,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
  <corners
      android:radius="1dp"
      android:topRightRadius="0dp"
      android:bottomRightRadius="0dp"
      android:bottomLeftRadius="0dp" />
  <stroke
      android:width="1dp"
      android:color="#E3E3E1" />

  <solid android:color="@color/blanc" />

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

android border android-linearlayout

138
推荐指数
8
解决办法
24万
查看次数

如何在android中的linearlayout周围显示阴影?

如何为线性布局显示阴影.我想要白色圆形背景和线性布局周围的阴影.到目前为止我已经这样做了.请帮我.提前致谢.

<LinearLayout
 android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@xml/rounded_rect_shape"
android:orientation="vertical"
android:padding="10dp">
<-- My buttons, textviews, Imageviews go here -->
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

和xml目录下的rounded_rect_shape.xml

 <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="rectangle" >

   <solid android:color="#ffffff" />

   <corners
      android:bottomLeftRadius="3dp"
      android:bottomRightRadius="3dp"
      android:topLeftRadius="3dp"
      android:topRightRadius="3dp" />
</shape>
Run Code Online (Sandbox Code Playgroud)

android roundedcorners-dropshadow android-linearlayout

75
推荐指数
7
解决办法
16万
查看次数

扩展Android View类以添加一个drophadow

我想进行扩展,LinearLayout以便在绘制布局时在其下方添加一个投影.我玩过这种onDraw方法但是我有点迷失了.任何有关这个甚至图书馆建议的帮助将不胜感激!

这是我想要实现的投影视图的示例.我不相信我可以在这里使用九个补丁因为我需要视图的内容在白框内.这意味着我需要知道边界与PNG末端之间的距离.但是我相信不同的屏幕密度意味着这个距离将始终是相同的PX但不是相同的DP.

所以要清楚我需要一种方法来扩展View类,以便在将它添加到布局时在其下面绘制阴影.请不要使用XML或9Patch解决方案.

在此输入图像描述

谢谢

插口

inheritance android view android-layout android-view

11
推荐指数
1
解决办法
1万
查看次数