有没有办法让CardView只在顶部有一个圆角半径?
<android.support.v7.widget.CardView
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:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="10dp"
>
Run Code Online (Sandbox Code Playgroud) 如何为线性布局显示阴影.我想要白色圆形背景和线性布局周围的阴影.到目前为止我已经这样做了.请帮我.提前致谢.
<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) 我想动画ShadowView一些坐标(到目标视图).
我正在使用D&D,如果用户使用drop(DragEvent.ACTION_DROP),那么在某些区域中的视图我想要为视图设置动画(从放置位置)到某个目标视图.
我不想从源位置动画视图,但想从DROP位置进行操作.
我尝试了很多东西,但没有任何作用.我怎样才能访问ShadowView?这也行不通:
EventDragShadowBuilder.getView()
Run Code Online (Sandbox Code Playgroud)
我认为TranslateAnimation应该适用于此,但我需要在D&D期间访问"阴影"视图.
我有FrameLayout与android:elevation ="4dp".这个高度的阴影朝下.我想改变阴影的方向.
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="100dp"
android:elevation="10dp"
android:layout_marginBottom="100dp"
android:background="@color/ColorPrimary"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
</FrameLayout>
Run Code Online (Sandbox Code Playgroud) 我想在布局的右侧和底部添加一个光影.我尝试使用android:background="@android:drawable/dialog_holo_light_frame"但是它在布局的所有四个边上都添加了一个厚阴影.我需要创建哪些可绘制并设置为背景?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@android:drawable/dialog_holo_light_frame">
<ImageView
android:id="@+id/g"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:layout_gravity="center"
android:src="@drawable/logo_icon"
android:visibility="visible"
android:clickable="true" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 材料设计非常强调"纸张"的隐喻.要做到这些,阴影是必不可少的.由于Material设计是一种哲学而不是API(尽管它被构建到L中),因此应该在任何地方(Windows窗体,HTML/CSS等)进行.我如何在Android API 14到20中执行此操作?
请注意,对于圆形和其他非方形形状,预制PNG实际上并不实用.
(1 个屏幕截图 - ImageView 可见性可见,2 个屏幕截图 - 消失)
使用ImageViewwith时,CardView我们可以说阴影根本不可见(尤其是在智能手机显示屏上)
<android.support.v7.widget.CardView
android:id="@+id/ImageViewWrapper"
android:layout_width="0dp"
android:layout_height="0dp"
android:elevation="0dp"
android:layout_margin="10dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:cardCornerRadius="6dp">
<android.support.v7.widget.AppCompatImageView
android:id="@+id/ImageView"
android:visibility="visible"
android:background="@color/black_1000"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
app:srcCompat="@drawable/ic_folder"/>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)
android:elevation 没有任何影响(0dp、5dp 或 20dp - 没有任何变化),所以我只是将其设置为 0dp
我们可以控制这个cardview shadow,让它更强/更大/更厚吗?
3 屏幕截图 - 这里是视频缩略图 ImageView 的 MX Player 应用示例(https://play.google.com/store/apps/details?id=com.mxtech.videoplayer.ad)
更新
我设置 app:cardElevation="7dp"
并app:cardUseCompatPadding="true"
没有进展......cardUseCompatPadding并使我的图像高度变小,现在我的左/右有黑条
在我的Android应用程序中,我必须实现类似下面给出的图像:

我已经尝试使用阴影xmls进行线性布局,但它似乎没有按照我想要的方式运行.我使用的代码是:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<shape
android:shape="rectangle">
<solid android:color="@android:color/darker_gray" />
<corners android:radius="5dp"/>
</shape>
</item>
<item android:right="5dp" android:left="5dp" android:bottom="15dp">
<shape
android:shape="rectangle">
<solid android:color="@android:color/white"/>
<corners android:radius="5dp"/>
</shape>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
请建议我如何实现这一目标.
我正在尝试绘制带有圆角的LinearLayout。
我想在运行时使用Colorfilter更改此布局的颜色。但ColorFilter不能应用布局,只能应用视图。
我不知道该怎么做到。
我怎样才能做到这一点?如果您能帮助我,我应该非常感激:)(对不起,英语简短,因为我是外国人:|)
我有一个LinearLayout,我想为它设置边框.它应该如下所示.
这是我的布局,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".activities.AddInfoMainActivity"
tools:showIn="@layout/app_bar_main">
<LinearLayout
android:id="@+id/add_info_layout_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/add_info_layout_one_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:id="@+id/add_info_layout_one_img01"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="24dp"
android:src="@drawable/sample01" />
<TextView
android:id="@+id/add_info_layout_one_txtView01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/add_info_txt_one_01"
android:textAlignment="center"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/add_info_layout_one_two"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:id="@+id/add_info_layout_one_img02"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="24dp"
android:src="@drawable/sample02" />
<TextView
android:id="@+id/add_info_layout_one_txtView02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/add_info_txt_one_02"
android:textAlignment="center"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent" …Run Code Online (Sandbox Code Playgroud)