&引用;android:elevation=";不';t使用编译API21在棒棒糖前的设备上工作
我试图在我的应用程序中使用&引用;android:elevation=";不';t使用编译API21在棒棒糖前的设备上工作,android,android-5.0-lollipop,android-elevation,Android,Android 5.0 Lollipop,Android Elevation,我试图在我的应用程序中使用“android:elevation=“”,但一旦运行,它就不会出现在使用android 4.1.2的设备中 gradle apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { applicationId "com.example.alvaro.proye
“android:elevation=“
”,但一旦运行,它就不会出现在使用android 4.1.2的设备中
gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.alvaro.proyectocaronte"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
layout.xml
<RelativeLayout
android:layout_width="1100dp"
android:layout_height="fill_parent"
android:background="@drawable/rounded_corner"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="93dp"
android:layout_marginEnd="93dp"
android:elevation="3dp"/>
也许我没有正确地为棒棒糖前的设备编译棒棒糖,有什么建议吗
如果您需要查看代码的其他部分,我将编辑问题
谢谢提升要求设备运行棒棒糖。有关如何模拟高程的回答,请参见更新的:
<android.support.v7.widget.CardView>
<YourLayout>
</android.support.v7.widget.CardView>
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.alvaro.proyectocaronte"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
android:background=“@android:drawable/dialog\u holo\u light\u frame”
它将为您提供提升的外观<?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="#BDBDBD"/>
<corners android:radius="5dp"/>
</shape>
</item>
<item
android:left="0dp"
android:right="0dp"
android:top="0dp"
android:bottom="2dp">
<shape android:shape="rectangle">
<solid android:color="#ffffff"/>
<corners android:radius="5dp"/>
</shape>
</item>
</layer-list>
您也可以使用支持库中的CardView 以实现曲面。
为此,请向build.gradle添加依赖项:
compile 'com.android.support:cardview-v7:23.1.1'
然后只需在布局中使用它:
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_margin="16dp"
android:background="#fff"
>
</android.support.v7.widget.CardView>
不要忘记添加xmlns:app=”http://schemas.android.com/apk/res-auto“
到根布局
此外,您还可以在代码中轻松更改高程:
CardView card = (CardView) findViewById(R.id.yourPreetyCoolCardView);
card.setCardElevation(getResources()
.getDimension(R.dimen.card_picked_up_elevation));
使用8dp
进行拾取,使用2dp
进行休息(通常)状态,您将非常棒。如前所述,您可以通过以下方式模拟棒棒糖前的高度:
android:background="@android:drawable/dialog_holo_light_frame"
迟来的评论。。但肯定对任何人都有帮助。。试试这个-谢谢@RanjithKumar,肯定会有帮助!!干得好。
android:background="@android:drawable/dialog_holo_light_frame"