我试图在我的应用程序中使用"android: elevation =",但是一旦运行,它就不会出现在带有Android4.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"/>也许我没有对棒棒糖前设备进行正确的编译,有什么建议吗?
如果您需要查看代码的其他部分,我将编辑这个问题
谢谢
发布于 2014-12-29 18:39:09
仰角要求设备运行棒棒糖。关于如何模拟高程https://stackoverflow.com/a/26747592/680249,请参阅这个答案
发布于 2016-03-10 12:04:16
更新了 ::
发布于 2016-04-01 12:38:49
您还可以使用支持库中的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>在这里,与使用@android:drawable/dialog_holo_light_frame作为背景相比,您可以更多地定制它。
编辑:
还请注意,这种方法允许简单地实现
材料设计上的预棒棒糖装置。
你可以改变海拔,
绕过拐角等。
要做到这一点,你必须:
app:cardElevation="8dp"
app:cardCornerRadius="8dp"
app:contentPadding="5dp">并且不要忘记将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用于休息(通常)状态,您将是非常棒的。
https://stackoverflow.com/questions/27693843
复制相似问题